Re: Should %d round?
- Posted by DerekParnell (admin) Mar 17, 2012
- 2116 views
petelomax said...
Further to a recent post, I would like to solicit general opinion on whether
printf(1,"%d\n",3.9999999)
should print 3 (as it does now) or 4?
I'm of the opinion that %d should display the integer portion of the number. If you need it rounded, do that explicitly.
printf(1,"%d\n",round(3.9999999))
However, I'll consider adding a rounding qualifier for the format() function, which is used by the formatting write routines. Something like ...
writefln("[r]",3.55) --> 4 writefln("[r10]",3.55) --> 3.6