Replies: 5 comments
-
Thanks for bringing this up. This is quite funny. Currently, there is no relation defined in math.js to convert Fractions to BigNumbers or vice versa, since it's ambiguous whether you would like to convert to one or the other. But the internally used To solve this, we have the following options:
I think option 1 (convert to BigNumber) would be the best default choice. If you want to have a Fraction as output, you can do so by first converting all arguments to Fractions. EDIT: there is an option 4, making this behavior configurable |
Beta Was this translation helpful? Give feedback.
-
I need more information about how mathjs behave before I can share which options makes more sense for my use case. Would the bignumber type be able to convert to exact fractions involving large numbers numerators or denominators? Either way, wouldn't the following be a fourth acceptable option?
|
Beta Was this translation helpful? Give feedback.
-
It indeed depends on the use case what's desired behavior.
Both aren't nice solutions, that's why we originally didn't want to choose one or the other and throw an error instead. Maybe option 3 is still the best. |
Beta Was this translation helpful? Give feedback.
-
There is another interesting discussion here: #694, which is about being able to have the num/den of a Fraction be represented with a BigNumber, and to be able to use BigNumbers and Fractions as the re/im parts of Complex values and the values of Units. |
Beta Was this translation helpful? Give feedback.
-
I updated the title of this issue. I think what we should do here is:
|
Beta Was this translation helpful? Give feedback.
-
I can't multiply bignumbers and fractions. Here's a failing test I added to function\arithmetic\multiply.test.js:
Beta Was this translation helpful? Give feedback.
All reactions