coinconvert / crypto-convert

Instantly convert cryptocurrency and get price information
https://coinconvert.net
Other
81 stars 17 forks source link

Wrong result when converting decimal numbers #11

Closed oleppe closed 1 year ago

oleppe commented 1 year ago

Hello,

The problem is when converting exponential values to USD (I didn't try converting to other currencies) it gives a wrong value. For example:

Convert['USDT'].USD(0.000000000263) result is 0.26272319 // wrong Convert['USDT'].USD(0.00000000263) result is 0 // wrong Convert['USDT'].USD(0.0000000263) result is 3e-8 // wrong Convert['USDT'].USD(0.000000263) result is 2.6e-7 // correct

i'm using the last version 2.1.5

el1s7 commented 1 year ago

Hi,

Thanks for your report. It has been fixed. A new option parameter has been added as well for decimal precision limit:

precision?: {
        /**
         * Default 4
         */
        fiat?: number,
        /**
         * Default 8
         */
        crypto?: number
    }