in reply to Using (s)printf()
I tried to use the example given in the text. This is what I get (using perl v5.6.1 built for cygwin):
printf("%.2f", 9.333333);
This prints "9.33". Actually, this is what I expect, but the article says it should be 9.34.
If I try the following: printf("%.1f", 9.55);
I get 9.6, which is OK, but if I try printf("%.1f", 43.55);
I get 43.5, which is rounded the wrong way.
Can someone explain this? (Please send me an email (oz1lo001@sneakemail.com)).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Using (s)printf()
by Hofmator (Curate) on Aug 31, 2001 at 16:20 UTC | |
by Anonymous Monk on Sep 01, 2001 at 07:29 UTC | |
by Hofmator (Curate) on Sep 03, 2001 at 15:32 UTC | |
by Zteven (Initiate) on Sep 02, 2001 at 15:08 UTC | |
by Iphigenie (Initiate) on Oct 09, 2001 at 14:39 UTC |
In Section
Tutorials