How to convert metres to centimetres in Monkey C?

1.8k views Asked by At

Serious newbie question, but I can't seem to find the answer anywhere!

I'm trying to convert my height from centimetres to metres in an application for my Garmin device. This is written in Monkey C (very similar to Java and C++ from what I understand).

Here's how I'm currently doing it:

var height = angus.height;
var heightCM = height.format("%0.2f");

My height is 175, and so as you might expect, this gives me a result of 175.00

I can't seem to find any resource that tells me how to essentially move a decimal to the left. Any help would be really appreciated.

Here's the documentation on formatting in Monkey C: https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/Lang/Number.html#format-instance_method

Any explanation on formatting numbers would be great. I'm also attempting to truncate a number, so from 1234567 to 1234, for example. So any information on that would also be great.

Thanks in advance!

1

There are 1 answers

0
AudioBubble On

You should use:

var height = angus.height / 100.0;