127. BigDecimal subtraction

JavaScriptAlgorithm
Is this helpful ?

few challengers  - accepted / - tried

This is a follow-up on 126. BigDecimal addition

In this problem, you are asked to implement the subtraction of two decimals with arbitrary digits.


subtract('-999999999999999999', '-1')
// '-999999999999999998'

subtract(
  '-999999999999999999.999999999999999999999999999999', 
  '1.0000000000000000000000000001')
// '-1000000000000000001.000000000000000000000000000099'

subtract(
  '999999999999999999.999999999999999999999999999999', 
  '-1.000000000000000000000000000001')
// '1000000000000000001'
  1. This problem covers 77. implement BigInt subtraction with sign.
  2. trailing zeroes in the result should be removed.

Let's try to solve this problem within 20 minutes.

Discuss