-
Notifications
You must be signed in to change notification settings - Fork 167
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
Is -0 < 0, regarding [EnforceRange]? #306
Comments
One of the simplest ways to clear this up might be for the top of the algorithm to just immediately set x to +0 if x is -0. |
It was pointed out in 5f1e6ce#commitcomment-20847302 that the tests for these cases weren't working. Fix the tests, and then fix the code correspondingly. Note that the spec isn't super-clear on this point; see whatwg/webidl#306.
I would hope not!
Sure. It's false in IEEE-754 in general, I believe. That is, But we could be pretty explicit about this, sure. |
I guess we should say we use IEEE-754. Might become more important with wasm bindings, though just spitballing here. |
Well. The return value of ToNumber is an ES Number, and those are defined https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type as:
We could try to be more explicit here, I guess, but we're working with a Number value here.... |
It's just unclear to me (both here and in the ES spec) whether when you do thinks like |
Ah, that's a good point. This part is definitely sucky. :( |
We never have that case, though. First step of the algorithm says:
|
Oh. Nevermind. We have similar issues in step 9 and 10:
:-/ |
Digging into this a bit further, from § 5.2 Algorithm Conventions in the ES spec says:
So I assume:
really means:
If this assumption holds, I could add a little bit of text at the beginning of § 3.2.4. Integer types that paraphrases the above quote and links to its source. |
But how would you interpret "return x" then? Does it allow returning -0? Again that seems unlikely since a Web IDL byte type (say) doesn't have a -0. |
Explicitly convert +0 and −0 to 0. Closes whatwg#306.
Explicitly convert −0 to +0. Closes #306.
[EnforceRange] will throw a TypeError
If lowerBound is 0 and x is -0, will this throw? Note that
-0 < 0
is false in JavaScript.The answer might be well-defined by ECMAScript conventions, but we should check that it is, and in any case we should add a note about this explicit case.
Note that the [Clamp] and no-extended-attribute cases don't have this problem as they explicitly censor -0 to 0. Although I guess clamp is a bit ambiguous, if "round -0 to the nearest integer choosing 0 instead of -0" will in fact change -0 to 0.
The text was updated successfully, but these errors were encountered: