Skip to content

Instantly share code, notes, and snippets.

@catdad
Created May 15, 2014 16:33
Show Gist options
  • Save catdad/b449244699f6cbd62616 to your computer and use it in GitHub Desktop.
Save catdad/b449244699f6cbd62616 to your computer and use it in GitHub Desktop.
Handling some common IEEE Floating Point math issues
var isZero = function(val){ return Math.abs(val) < 1.0e-14; }
var isNegative = function(val){ return (val < 0) ? true : val === 0 && (1/val)===-Infinity; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment