#!/opt/perl5/bin/perl
$var = "1.5";
$var2 = sprintf("%.0f\n", $var);
print $var2;
$var3 = 1.5000001;
$var4 = sprintf("%.0f\n", $var3);
print $var4;
The first Print statement yields 1. The second yields 2.
I am using PERL Version 5.006 (result from command below) running under
HP-UX 10.20.
.-. --..
-----Original Message-----
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 24, 2004 10:51 AM
To: Zielfelder, Robert; 'Perl Beginners List (E-mail)'
Subject: RE: Rounding of floating point numbers
Zielfelder, Robert <[EMAIL PROTECTED]> wrote:
:
: Actually, the % is there in my program, I forgot to type it in the
: e-mail....With or without it, the result ends up being ".0f"....
: I think I have 5.6.0, that might be the problem....
You can test for your version with:
printf "perl version: %s\n", $];
I don't have a surviving copy of 5.6.0 for testing. I doubt
it was a problem in 5.6.0 since there is no bug fix mentioned
in perl561delta of a bug fix. Can you show the code you are
using for testing?
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>