You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TinyJS seems to treat integers differently from other numbers?
enno@erdbaer:~/src/tiny-js@master$ ./Script
> Interactive mode... Type quit(); to exit, or print(...); to print something, or dump() to dump the symbol table!
print(5/2);
> 2
print(5.0/2);
> 2.500000
print(123 === 123.0);
> 0
Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.
JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.
Yes, unfortunately TinyJS isn't very spec compliant. It hasn't been maintained in ages - you may find that other engines like mjs do a better job for you?
Honestly the best bet would probably be to rip out all the integer maths stuff - it'd simplify the code quite a bit and would then be spec compliant.
Activity
gfwilliams commentedon Jan 4, 2022
Yes, unfortunately TinyJS isn't very spec compliant. It hasn't been maintained in ages - you may find that other engines like
mjsdo a better job for you?Honestly the best bet would probably be to rip out all the integer maths stuff - it'd simplify the code quite a bit and would then be spec compliant.
ennorehling commentedon Jan 5, 2022
I didn't know about
mjs, but that looks like it will work. Thanks!