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
Float reading and writing is inconstent on Kotlin JS #322
Comments
As The only thing we can improve here is stressing this peculiarity in docs. |
Thanks for the clarification. As there is also writeDouble/readDouble, this is very unexpected if you don't know that JS is only using 64-bit floating points underneath. I don't know if it is possible to trim the float values to 32-bit precision stored in a 64-bit variable? |
Sure, it's possible, but with potential precision loss (which is always the case for values that could not be represented exactly, like While JS Numbers are always double-precision floating point numbers, JS also provides TypedArrays, where values have fixed width in binary representation. When writing values into these arrays, 64-bit fp Numbers are converted to an arrays' type (in fact, semantics is defined for storing in array's buffer, with the float64 to float32 conversion described here). To "trim" double-precision fp to a single-precision fp, Kotlin's
|
Addresses concerns described in #322
Addresses concerns described in #322
Float behaving as Double in KotlinJS is discussed here. |
Hey,
the following snippet
gives this result.
JVM works fine.
The text was updated successfully, but these errors were encountered: