krkarthik_info
9 years agoFrequent Contributor
How to get the number of decimal places in a given number
Hi,
I have a scenario where I need to get the number of decimal digits after the decimal point. Please refer below ex.
I want a function where I give this number as input and the function should return 4. As there are 4 decimal digits including trailing zeros.
var number = 123.1000;
Kindly someone help.
Thanks,
Karthik K R
function count_fraction_length()
{
var number_to_string = "123.1000";
var length = number_to_string.length;
var position = number_to_string.indexOf(".")+1;
Log.Message(length-position);
}
You may need to convert duble to string.