implement BigInt division
2022年5月1日小于 1 分钟
implement BigInt division
Question
This is a follow-up on 114. implement BigInt multiplication.
You are asked to create a BigInt division function.
divide(
'1123456787654323456789',
'1234567887654323456'
)
// '910'
divide(
'-1123456787654323456789',
'1234567887654323456'
)
// '-910'
Notice the result should be rounded towards 0.
divide(
'5',
'2'
)
// '2'
divide(
'-3',
'2'
)
// '-1'
Code
/**
* @param {string} a
* @param {string} b
* @return {string}
*/
function divide(a, b) {
// your code here
}