Skip to content
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

strutils:formatSize() is broken in JS mode #8231

Closed
genotrance opened this issue Jul 7, 2018 · 2 comments
Closed

strutils:formatSize() is broken in JS mode #8231

genotrance opened this issue Jul 7, 2018 · 2 comments

Comments

@genotrance
Copy link
Contributor

import strutils

echo formatSize(2462056448, '.', bpIEC, false)

Echos 2.293GiB for C/C++ mode but 37568YiB for JS mode. Fails test case in strutils.nim but isn't getting caught since testament doesn't actually run the test, just compiles due to separate bug.

@ghost
Copy link

ghost commented Jan 23, 2020

I've investigated a bit, and it seems to be like that because bitwise operators in JS are 32-bit, so 1 << 40 gives 256 and not 1099511627776
A possible fix might be to make custom JS functions for bitwise operations so they'll work on both 32-bit and 64-bit

bung87 added a commit to bung87/Nim that referenced this issue Jul 25, 2020
bung87 added a commit to bung87/Nim that referenced this issue Aug 24, 2020
Araq pushed a commit that referenced this issue Aug 25, 2020
* avoid #8231, bitwise move to mul,div

* add test for #8231

* fix bitwise move when div result is float

* bitwise move depends on typ.size
@mratsim
Copy link
Collaborator

mratsim commented Aug 26, 2020

Fixed by #15070

@mratsim mratsim closed this as completed Aug 26, 2020
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
* avoid nim-lang#8231, bitwise move to mul,div

* add test for nim-lang#8231

* fix bitwise move when div result is float

* bitwise move depends on typ.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants