I can calculate for example
x = 0.28
y = 1e18
x * y = 280,000,000,000,000,000
How can I do this in javascript while x could be any number, including ints, and y could be any other big number like 1e12 or whatever.
I can calculate for example
x = 0.28
y = 1e18
x * y = 280,000,000,000,000,000
How can I do this in javascript while x could be any number, including ints, and y could be any other big number like 1e12 or whatever.
You can't mix BigInt with other types in a calculation, so you need to use BigInt for all the operands.
So instead of multiplying the float by
0.28, multiply by28nand divide by100n.