how to return the number of decimals after the comma in c or javascript?

Asked

Viewed 297 times

1

How to return the number of decimals after the comma in c or javascript;

Example:

To the entrance

2.254

The exit would be

3

  • You want to know the number or numbers after the comma?

  • 1

    Put your number in a variable, pass it to string, split the string at the point and then count the characters: var a = 1.2345; a.toString().split('.')[1].length

  • What you seek is not rounding?

  • Is that something you’re looking for? https://jsfiddle.net/cpjw12ub/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.