Skip to main content
gamedev.net
🔒 Locked

limiting a double

Started by Dovyman 2 replies 300+ views
Original Post
Dovyman
Dovyman
I have a c++ timing function that returns a double, I want to output this time to a log file, but I want the spacing to be aligned well, and I noticed that the first few entries are small enough that they are outputted using scientific notation. How can I tell it to just round to a specific number of digits all the time?
amag
amag
You do this when you write the double to the file. Like:
fprintf(fp, "%.2f", my_double);
This will limit the double to two(2) digits after the decimal dot(.).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.