math: inconsistent conversion from NaN to int on js/wasm #35034
Labels
arch-wasm
WebAssembly issues
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?windows/amd64
js/wasm
go env
OutputWhat did you do?
The following program converts a NaN to int32.
The conversion is different on js/wasm, if math.NaN() is used or the bit pattern, even if both seem to be identical.
To run the wasm program, it is compiled with:
GOOS=js GOARCH=wasm go build -o main.wasm main.go
and loaded in a browser with the method described in github.com/golang/go/wiki/WebAssembly
What did you expect to see?
On playground and windows/amd64 the result is as expected:
NaN -2147483648 9221120237041090561
NaN -2147483648 9221120237041090561
I expect to see the same result in the js console when running the wasm program.
What did you see instead?
on js/wasm the result is:
NaN -2147483648 9221120237041090561
NaN 0 9221120237041090561
Both chrome and firefox give the same result.
The text was updated successfully, but these errors were encountered: