in reply to [OT: JavaScript] JS remainder operation ('%')
According to 2 online JS calculators (https://playcode.io/new and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder) the result is 859064762.882.
I get 859064762.875 from both of those when using FireFox, and from the FireFox console. (It's not surprising they all give the same result since they all use the JS engine in my browser.)
I get 859064762.875 from both of those when using Chrome, and from the Chrome console. (Again, the consistency is to be expected.)
What kind of machine are you using?
Note that they are are two common modulo operators in CS ("floored" and "truncated"), and it varies a lot by language.
| Perl | % | Floored |
| POSIX::fmod | Truncated | |
| JavaScript | % | Truncated |
This only matters if an operands is negative, though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [OT: JavaScript] JS remainder operation ('%')
by NERDVANA (Priest) on Jan 17, 2024 at 18:42 UTC | |
|
Re^2: [OT: JavaScript] JS remainder operation ('%')
by LanX (Saint) on Jan 17, 2024 at 21:51 UTC | |
|
Re^2: [OT: JavaScript] JS remainder operation ('%')
by syphilis (Archbishop) on Jan 18, 2024 at 01:57 UTC | |
by ikegami (Patriarch) on Jan 18, 2024 at 14:31 UTC |