Do we have any Funtion like Round (Ex: 2.5698 to 2.5)

Former Member
Former Member
Hi,

Is there any Function to get the rounded value. Please see below example;

I have a variable which will return 6.2538000 and I want to display it like 6.2
Normally in programing we use Round function. In Connect IQ do we have any function to get the result like this.

Thank You.
  • 205

    Hi,

    Is there any Function to get the rounded value. Please see below example;

    I have a variable which will return 6.2538000 and I want to display it like 6.2
    Normally in programing we use Round function. In Connect IQ do we have any function to get the result like this.

    Thank You.




    var i=6.2538000;

    var forDisplay=i.format("%.1f"); //returns a string
  • Former Member
    Former Member over 9 years ago
    Thank You Jim. Its work.:)
  • Thank You Jim. Its work.:)


    format() has many options - pretty much like the formatting in c's printf() function. "%x" for hex, "%d" for decimal (integer), "%02d" for 2 digit, zero filled, etc...