Closed ellis closed 8 years ago
Well, basically we should implement the BigNumber version of random
to solve this correctly :)
When you multiply a number and a BigNumber, math.js converts the number to a BigNumber and then applies the multiplication to the two BigNumbers. The conversion warning you get is there for a reason: when you have a number with >15 digits, it's a number that contains round off errors. When converting such a value to a BigNumber, you would get a false idea of working at high precision. This error forces you to explicitly convert to a BigNumber yourself, to force you to understand what you're doing. In your example, not throwing this error would give the user a false idea that he's dealing with a 64 digit random number which is not the case.
Thanks for the info. As a side question, is there perhaps a configuration option to allow for the implicit conversion to take place anyway?
There is currently no such option, I've updated a related issue, let's continue the discussion there ok?
See #710.
The following code crashes:
The error message is:
I would like my users to be able to use
random()
in calculations without having to explicitly convert between number and bignumber. Does that make sense?