Forum Discussion

krkarthik_info's avatar
krkarthik_info
Frequent Contributor
8 years ago
Solved

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...
  • PanB's avatar
    8 years ago

    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.