input : -81.82637799999999(14 numbers after decimal point)
输入:-81.82637799999999(小数点后14位数)
output :-81.8263779999999(13 numbers after decimal point)
输出:-81.8263779999999(小数点后13位数)
How can I implement this using javascript?
如何使用javascript实现这一点?
1 个解决方案
#1
0
Well try this. See if it works for you
好吧试试吧。看看它是否适合你
var x = -81.82637799999999;
x = x.toString(); // convert to string
alert(x.length);
x = x.substring(0, x.length - 1); // cut out last character
alert(x.length);
x = parseFloat(x); // convert it back to float
#1
0
Well try this. See if it works for you
好吧试试吧。看看它是否适合你
var x = -81.82637799999999;
x = x.toString(); // convert to string
alert(x.length);
x = x.substring(0, x.length - 1); // cut out last character
alert(x.length);
x = parseFloat(x); // convert it back to float