Closed element6 closed 10 years ago
nevermind, it's the number of digits, isn't it?
I'm not sure exactly what you're asking. obj.num / obj.denom
will return a Javascript number because bigInt
s have the valueOf
method overloaded.
BigRat(obj.num).over(obj.denom).toDecimal()
will do the same thing, except it will be slower and more precise.
Possibly a stupid question, can we just do 'obj.num / obj.denom' (and .toString if want to keep backward compatibility, although I think number makes more sense)?
In what case, would this approach not work over the existing toDecimal()?
Cheers, Gary