I am building an app that displays how many miles you have gone and I want it to have 3 decimal places. So "0.435 miles" for instance. I have tried the code below:
static char stopwatch_miles[50];
snprintf(stopwatch_miles, sizeof(stopwatch_miles), "%.3f miles", num_miles);
text_layer_set_text(miles_layer, stopwatch_miles);
num_miles
is a calculated floating point variable. However, Pebble deprecated using floats in snprintf
in 1.13. Is there an easy workaround? Maybe using an int
, multiplying it by 1000 before my math and adding the decimal places in formatting?