You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
930 B
36 lines
930 B
const num = {
|
|
// 清除浮点
|
|
// 乘法
|
|
ride(a, b) {
|
|
var as = Math.pow(10, digitLength(a))
|
|
var as2 = Math.pow(10, digitLength(b))
|
|
if (digitLength(a) >= digitLength(b)) {
|
|
return (as * a * as * b) / as / as//这里要除以最小公倍数的平方
|
|
} else {
|
|
return (as2 * a * as2 * b) / as2 / as2
|
|
}
|
|
function digitLength(e) {
|
|
var e1 = (e + '').split('');
|
|
var e2 = e1.findIndex((item) => item = '.')
|
|
return e1.length - 1 - e2;
|
|
}
|
|
},
|
|
|
|
// 除法
|
|
except(a, b) {
|
|
var as = Math.pow(10, digitLength(a))
|
|
var as2 = Math.pow(10, digitLength(b))
|
|
if (digitLength(a) >= digitLength(b)) {
|
|
return ((as * a) / (as * b))
|
|
} else {
|
|
return ((as2 * a) / (as2 * b))
|
|
}
|
|
function digitLength(e) {
|
|
var e1 = (e + '').split('');
|
|
var e2 = e1.findIndex((item) => item = '.')
|
|
return e1.length - 1 - e2;
|
|
}
|
|
},
|
|
|
|
};
|
|
export default num;
|
|
|