I am trying to do this:
const numerator = 268435456;
const denominator = 2 ** 64;
const decimalFraction = numerator / denominator;
To make this work, I have tried to use the code suggested here: https://stackoverflow.com/a/54409977/3846032:
const rawValue = 268435456n;
const exponent = 2n ** 64n;
const precision = 100_000_000;
const fraction = Number((rawValue * BigInt(precision)) / exponent) / precision;
When I run this in dev it works fine, but in prod I get this error:
Uncaught TypeError: can't convert BigInt to number
I believe it is coming from 2n ** 64n
.
I'm using create-react-app and some digging reveals this: https://github.com/facebook/create-react-app/issues/6907#issuecomment-778178677).
Unfortunately this suggestion makes it fail in both dev and prod with an OOM error.
Any suggestions on how to make this work would be appreciated.