3 ms·
How many FLOP do you need to add two rationals? We don't have int type in javascript, only bigInt but it not supported in some browsers and probably not fast en
by munrocket 7y ago
How many FLOP do you need to add two rationals? We don't have int type in javascript, only bigInt but it not supported in some browsers and probably not fast enough.
UPD: I added Fraction.js to benchmark https://munrocket.github.io/double.js/docs/benchmark.html https://munrocket.github.io/double.js/docs/benchmark.html but it slower and overflows for some reason, .round(31) not helps.
- ktpsns 7y agoAdding two rationals boils down to adding 2x two integers. Integer arithmetic is in general less complex then floating point arithmetic. But of course that's not true if your hardware supports single instruction double floating point arithmetic (which any relevant 64bit architecture does).
- munrocket 7y agoThe problems begins when calculations is long and int64/int32 not enough to store full fraction precision. Lol seems that I find a bug in Fraction.js in rounding https://runkit.com/munrocket/fraction-js-test https://runkit.com/munrocket/fraction-js-test, but it used in popular Math.js library.