0

input : -81.82637799999999(14 numbers after decimal point)

output :-81.8263779999999(13 numbers after decimal point)

How can I implement this using javascript?

Community
  • 1
  • 1
Neha
  • 13
  • 4

1 Answers1

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

https://jsfiddle.net/9sngtp3n/1/

Siddhartha Chowdhury
  • 2,724
  • 1
  • 28
  • 46