-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deterministic NaN
#108
Comments
Engines could indeed just restrict |
There are, in fact, two options for NaN normalization:
|
My proposal is for the second of those: sign bit 0, quiet bit 1, and the rest of the payload zero. This is And in addition to "default NaN" mode on ARM, this is the behavior of RISC-V too. And it's consistent with what some popular toolchains do; for example, |
All bits set to 1 is not canonical, though it is easy to produce in practice. Canonical pattern with sign bit 1 is produced by shifting that value by a constant amount.
Both sign 0 and sign 1 are canonical. I think you have measured it, and would be curious to see how you were able to enforce this pattern on x86. Unlike the other canonical pattern, it would be impossible to produce this variant form binary
The reason for having a single |
I implemented it on x86 using a load from a constant pool. It has a cost, and I'm not proposing anyone pay it that doesn't want to. |
The component model also has a concept of a canonical NaN, which matches the one I'm proposing here. |
How would anyone avoid paying the cost if that this gets standardized? |
The rest of the presentation is about proposing a new relaxed-math mode. Canonicalization would not be required in that mode. |
@sunfishcode proposed to add deterministic
NaN
behavior if this proposal adds a 'strict' mode.I am curious to discuss this a bit, regardless of whether or not it will become part of the strict mode. Mainly I am curious if it has to become part of the spec as engines can restrict
NaN
patterns without violating the spec today.The text was updated successfully, but these errors were encountered: