purescript / purescript-prelude

The PureScript Prelude

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Precision loss for 32-bit integer multiplication

iamahuman opened this issue · comments

exports.intMul = function (x) {
return function (y) {
/* jshint bitwise: false */
return x * y | 0;
};
};

I can't believe this was never mentioned as an issue before.

Maybe replace this with Math.imul?

My bad.

Closing as duplicate (but I think it might have fit here more...)

No worries, it's split between both! 🙂

The numeric operations are inlined by the compiler where it can (kinda, the compiler produces code equivalent to their implementation here, it doesn't technically inline since it doesn't look at the JS implementation of them).