grain
grain copied to clipboard
Add NaN and Infinity Literal Syntax
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
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 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.
OK, thank you. I've opened a separate issue.
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.