Round to 2 decimal places

Hi, does anyone know how to round distance to 2 decimal places, I have the formula for calculating distance in miles but it goes to several decimal places, I’d like it to only display 2? For example, instead of 4.12344626 etc it would show 4.12

2 Likes

Welcome - this is the best watchface making community there is - you will always find help here. I recommend you reading all the posts here as most questions have been asked and answered previously. Use the search box in the top right hand corner and you will more than likely find your answer and if you really get stuck you can post here and you will get help for sure

4 Likes

You will find everything you need about steps converted into miles/kilometer calories and amount of time walking, in the tutorial by TOMAJA here: [TOMAJA Mini Tutorial] How to Convert Steps into Miles, Kilometres, Calories & Sport Time

4 Likes

The mentioned tutorial is good for providing formulas in general, meanwhile was the set of available functions extended with the toFixed(number, digits) function, which truncates a number to a decimal precision based on the digits value specified. For example (toFixed (4.12344626, 2)) returns 4.12 (do not forget to put the whole formula in brackets, for the result to be displayed as number).

6 Likes

:disguised_face: Wow :face_with_spiral_eyes: That’s a brilliant Tutorial there my friend :nerd_face:

3 Likes

That’s brilliant, toFixed works fine, many thanks!

2 Likes

the cavalry, … quick and fast!

1 Like