BigDecimal Division
2022年5月1日小于 1 分钟
BigDecimal Division
Question
This is a follow-up on 126. BigDecimal addition
In this problem, you are asked to implement the division of two decimals with arbitrary digits.
divide(
'100000000000000.1',
'-0.001'
)
// '-100000000000000100'
divide(
'-0.123',
'-0.00971'
)
// '12.66735324407826982492'
- This problem covers 115. implement BigInt division.
- trailing zeroes in the result should be removed.
- return the result with max 20 digit fraction part, rest be truncated.
Code
/**
* @param {string} a
* @param {string} b
* @return {string}
*/
function divide(a, b) {
// your code here
}