#Avoid showing negative zero on a countdown timer?

3 messages · Page 1 of 1 (latest)

dusty lichen
#

Hey all, I have a timer counting down in a Step event like so:

if (time_left > 0) {
    time_left -= delta_time / 1_000_000;
    if (time_left < 0) {
        time_left = int64(0);
    }
} else {
    active = false;
}

I also am displaying the timer through draw_text and using string_format to limit the timer to 2 decimal places. However, when the timer reaches zero, sometimes it displays -0.00. How can I make it only display 0.00 upon reaching the end?

#

Avoid showing negative zero on a countdown timer?

#

Ok the problem seems to go away when I changed time_left < 0 to time_left <= 0