medium - accepted / - tried
For some basic calculations, you might use
Number.prototype.toFixed() to overcome this, yet for more extreme cases that requires perfect accuracy, it is not enough.
In this problem, you are asked to implement the addition of two decimals with arbitrary digits.
add('-999999999999999999', '-1') // '-1000000000000000000' add( '-999999999999999999.999999999999999999999999999999', '1.0000000000000000000000000001') // '-999999999999999998.999999999999999999999999999899' add( '999999999999999999.9999999999999999999999999999', '1.0000000000000000000000000001') // '1000000000000000001'
- This problem covers 76. implement BigInt addition with sign.
- trailing zeroes in the result should be removed.