asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

Signed/Unsigned mismatch in README #43

Closed ScatteredRay closed 10 years ago

ScatteredRay commented 11 years ago

In the README example, for the code: ((((x+1)|0)>>>0)/(x|0))>>>0; the first fragment A == (((x+1)|0)>>>0)' which returns an unsigned and the secondB == (x|0)returns a signed. This causes the divideA/B` to have a sign mismatch. What's the desired behavior of this expression, Should it fail? If so what should it be changed to?

kripken commented 11 years ago

I think it just needs parentheses around the second expression, so it is unsigned too. @dherman ?

ScatteredRay commented 11 years ago

I think that seems most likely, and seems to stop the error from occurring.

cscott commented 11 years ago

@kripken just to be clear, you're suggesting to change the expression to: (((x+1)|0)>>>0)/((x|0)>>>0); ?

kripken commented 11 years ago

Well, reading it now, i am not sure what @dherman intended there actually.

sunfishcode commented 10 years ago

Fixed in 77b6caedd9f1aa8628e3d2e1a38b9eac71df95b7.