grain icon indicating copy to clipboard operation
grain copied to clipboard

Add NaN and Infinity Literal Syntax

Open peblair opened this issue 3 years ago • 4 comments

See title. Open questions:

  • What syntax should we use?
  • Should they be F32 or F64? We should probably have both, since F32/F64 NaN comparisons may not work correctly (need to check)
  • Perhaps others

peblair avatar Jun 04 '21 09:06 peblair

I think this is a duplicate of #360.

As a user I actually need to detect NaNs ind +/-infinite Numbers, but I think it needs to be done with functions like numberUtils.isNaN, which is for WASM primitives and not exposed.

cician avatar Jun 06 '21 09:06 cician

@cician This is actually talking about the syntax, whereas #360 is referring to the constants. As for the isNaN and isFinite predicates, we should definitely add those. I think we should open a separate issue for that.

peblair avatar Jun 06 '21 10:06 peblair

OK, thank you. I've opened a separate issue.

cician avatar Jun 06 '21 10:06 cician

What syntax should we use?

I vote for NaN and Infinity.

Should they be F32 or F64? We should probably have both, since F32/F64 NaN comparisons may not work correctly (need to check)

Great question. Float literals of the Number type default to f64s, so I say we remain consistent. I think questions of equality should probably be handled by the operators.

As a side note, I would probably just make coerceFloat32ToNumber promote to an f64 and then simplify the Number operations to only worry about f64s and avoid the equality issue altogether.

ospencer avatar Dec 28 '21 23:12 ospencer