roc icon indicating copy to clipboard operation
roc copied to clipboard

Add Num.infinityF32 and F64, Num.nanF32 and F64

Open rtfeldman opened this issue 1 year ago • 0 comments

Currently there's no way to directly ask for infinity, -infinity, or NaN. There should be:

  • [x] https://github.com/roc-lang/roc/pull/6711 Add builtins for Num.infinityF32 : F32, Num.infinityF64 : F64, Num.nanF32 : F32, and Num.nanF64 : F64 - at first, they can just be equal to expressions which evaluate to those (e.g. infinityF32 = 1 / 0, nanF64 = 0 / 0).
  • [ ] Make a separate issue to replace the = 1 / 0 implementations with compiler-generated numbers, since that will result in better runtime perf in dev builds.
  • [ ] Change the repl so that for infinity, we print out Num.infinityF32 or Num.infinityF64 instead of and -∞ today (use infinityF64 if the number's type is Frac *), and do the same for nan. For negative infinity, print out -Num.infinityF32 or -Num.infinityF64. Relevant code is here; some tests will also need to be updated.

rtfeldman avatar May 02 '24 23:05 rtfeldman