Ranter
Join devRant
Do all the things like
++ or  rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Comments

@theuser
"JS has floating points issues" is a common complaint on the internets, usually a shitpost. 
Rambolus9530dI think the problem is behind the keyboard, JS is doing exactly what you are asking for... As suggested use to fixed and give it a 20 parameter. If you want the full number not caring how many numbers there are behind the decimal point just use the number itself. You don't need a to fixed or to precision

iiii232430d@leocast you cannot precisely represent any float number with a float part which is divisible by 0.1 (except 0.5) because computers work in binary and in binary such number is represented as an infinitely long series of binary digits
think of it as a value of (x1*1/2 + x2*1/4 + x3*1/8 + ...) 
hardfault206130dI don’t understand the bashing
IEEE 754 cannot represent float precisely. There mightbe other notation that can, it doesn’t have to do anything with how computer works
But rather how JS represents things 
Root6856030dDo you want floating point math or slow as beans string math?
Tip: you want floating point math. 
FastNop2924930d@hardfault Expecting a binary floating point arithmetic to represent decimal fractions exactly, that's failing to understand how computers work. Binary system on binary machines. It has nothing to do with JS.

hardfault206129d@FastNop so long back I saw a video by pebble FW developers in which they used fix point numbers with finite precision to represent floating point to get higher performance in execution time and size, they introduced a new math lib called sllmath(sign long long math)
IEEE 754 is fast because many processors have FPU but the Many Arm Cortex M series doesn’t have there libgcc emulate IEEE 754.
I don’t wanna associate working of computer with IEEE 754 
FastNop2924929d@hardfault The root cause is that decimal fractions like 0.1, 0.01 etc have no exact representation in the binary floating point system, just like 1/7 has no exact (and finite) representation in the decimal system.
This is obvious to everyone who understands the binary system  and thus, how a computer works. 
hardfault206129d@FastNop agree not possible in binary fixed point , but possible in decimal fixed point
It’s just my definition of computer is anything that is truing complete , number representation can vary. I thought we are discussing a broader topic of what is a computer .
Still don’t agree with unnecessary basing of OP
Food for thought if we wanna represent 0.01 in binary
We need 3 element
1. Integer part 0 (signed )
2. Significant fractional part (unsigned)
3. power of ten (signed)
all these can be stored in binary.
( we can be tricky with 2 and 3)
I know we represent things in binary because logic gates, but computing can be bit more vast, believe me base n gates are coming ( but they won’t be called gates) i just don’t like the close minded bashing. 
FastNop2924929d@hardfault Well of course you could do computations in any base. You could even abuse strings to do math. It's just that the performance of such yoyo code would suck. That's why people use the binary system on binary computers which are the ones we've had for decades.

hardfault206129d@FastNop again there are many cases where performances of these yoyo math is higher than emulation of floating point
Related Rants
I love JS but sometimes, uh...
rant
js
bug
float
decimals