Yaffle / BigDecimal

a polyfill for decimal propocal
MIT License
51 stars 7 forks source link

Print and read back #6

Closed munrocket closed 1 year ago

munrocket commented 1 year ago

It looks like some of the methods not implemented for Base10/Base2 this lead to problem that it is impossible to print and read back BigFloat/BigDecimal.

Maybe I miss something? Should I use .toFixed() and remove trailing zeros?

Yaffle commented 1 year ago

The problem is that 0.1 cannot be represented in the used binary structure. And the spec proposal has no details how to do this. Perhaps, BigFloat.round should accept decimal string and rounding should be applied. I have decided to skip it so.

munrocket commented 1 year ago

I should switch to BigDecimal because BigFloat constructors is not flexible enough.

Yaffle commented 1 year ago

May be, BigFloat should be separated into another small libraries where no transendent math is needed and no string conversion methods, as today my implementations arenot perfect. For BigDecimal they can be simplified a lot as base convertion is not needed

munrocket commented 1 year ago

Yea, can be a good idea, but string conversions always needed in any application. I like the implementation but API can be easier like in wasm/big.js. Right now I am using it with wrapper because of that.

munrocket commented 1 year ago

I think you can add it in https://github.com/josdejong/mathjs after that.