josdejong / mathjs

An extensive math library for JavaScript and Node.js
https://mathjs.org
Apache License 2.0
14.31k stars 1.24k forks source link

valueOf() return ? #3217

Closed marsDes closed 2 months ago

marsDes commented 3 months ago

typeof  math.multiply(1,2).valueOf()  // number   2

typeof math.multiply(math.bignumber(1.0),2).valueOf()  // string  '2'
`
marsDes commented 3 months ago

@josdejong

josdejong commented 3 months ago

Yes, that is how it works.

BigNumber converts into a string because normally its value cannot be represented correctly using a number (otherwise there would be no reason to use BigNumber in the first place).

josdejong commented 2 months ago

Closing due to a lack of response.