Add Float.isNaN and related Float predicates #2243
Comments
|
Can we please add predicate functions to Float that test for +Infinity, -Infinity and NaN. Haskell's GHC does it with FFI calls. |
|
Good idea. I think we can just have |
|
https://github.com/unisonweb/unison/blob/trunk/docs/adding-builtins.markdown is (I think?) mostly up to date if you feel like having a go at this one. :) |
|
These comments from primFloat.c say how to test for these: /* Floating point NaN iff exponent is all ones, mantissa is
non-zero (but see below.) */
/* A float is Inf iff exponent is max (all ones),
and mantissa is min(all zeros.) */
/* A (single/double/quad) precision floating point number
is denormalised iff:
- exponent is zero
- mantissa is non-zero.
- (don't care about setting of sign bit.)
*/
/* sign (bit 31) set (only) => negative zero */ |
|
@philderbeast ah that's a good point, if we just have a bitwise cast from |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

If someone looks at this, it might also be a good moment to consider whether we should be able to parse or pretty-print float values Infinity, -Infinity and NaN. (comment)
Originally posted by @atacratic in #611 (comment)
The text was updated successfully, but these errors were encountered: