1 | var helperNumberDecimal = require('./helperNumberDecimal')
|
2 | var toNumberString = require('./toNumberString')
|
3 | var multiply = require('./multiply')
|
4 |
|
5 | function helperNumberDivide (divisor, dividend) {
|
6 | var str1 = toNumberString(divisor)
|
7 | var str2 = toNumberString(dividend)
|
8 | var divisorDecimal = helperNumberDecimal(str1)
|
9 | var dividendDecimal = helperNumberDecimal(str2)
|
10 | var powY = dividendDecimal - divisorDecimal
|
11 | var isMinus = powY < 0
|
12 | var multiplicand = Math.pow(10, isMinus ? Math.abs(powY) : powY)
|
13 | return multiply(str1.replace('.', '') / str2.replace('.', ''), isMinus ? 1 / multiplicand : multiplicand)
|
14 | }
|
15 |
|
16 | module.exports = helperNumberDivide
|