Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

division by zero inconsistent with IEEE 754 standard #156

Open
cloudcell opened this issue May 1, 2023 · 0 comments
Open

division by zero inconsistent with IEEE 754 standard #156

cloudcell opened this issue May 1, 2023 · 0 comments

Comments

@cloudcell
Copy link

Assuming that this calculator runs on ganja, I came across this behavior:
image
which is correct according to IEEE 754.
On the other hand,
image
which is incorrect.

I've done some analysis using ganja coffeeshop to help resolve this bug sooner. Here's a small reproducible example:

// Create a Clifford Algebra with 3,0,1 metric
Algebra(3,0,1,()=>{
    
    var A = 1e0123;
    var R = 1/(A*(~A)); // results in NaN - not according to IEEE 754.
    var S = 1/R; // the S is zero (empty) in the interface but NaN in the console.
    var T = 1/0; // works according to IEEE 754 (results in Infinity) - ok!
 
    // print into console
    console.log("R: ", R);
    console.log("S: ", S);
    console.log("T: ", T);
 
    // Produce a graph in 3D
    document.body.appendChild(this.graph(()=>{
        return [
            0xFF0000, R, "R", // our test point
            0x00FF00, S, "S",
            0x0000FF, T, "T",
        ];
    },{
        grid:true,      // draw a grid
        labels:true,    // draw axis labels
        lineWidth:3     // set the width of the lines connecting the points
    })); // end of graph
}); // end of Algebra

In short, ganja seems to follow IEEE 754 (the standard which describes, among many other things, the treatment of the division by zero) when it deals with real numbers, while it produces NaN's when it deals with zero multivectors. One thing I've noticed is that the coffeeshop interface does not display NaN values which (possibly) makes one assume that the values are all zeroes. So, PERHAPS, the reason we're getting zeroes (in the "calculator example" above) is because NaN's get interpreted as empty values and empty values get interpreted as zeroes later... just a guess. HTH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant