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....




.-.  --..

 -----Original Message-----
From:   Charles K. Clarkson [mailto:[EMAIL PROTECTED] 
Sent:   Tuesday, February 24, 2004 10:27 AM
To:     Zielfelder, Robert; 'Perl Beginners List (E-mail)'
Subject:        RE: Rounding of floating point numbers

Zielfelder, Robert <[EMAIL PROTECTED]> wrote:
: 
: I am trying to figure out why the following doesn't work the 
: way I would expect it to:
: 
: $var1 = 1.5;
: $var2 = sprintf(".0f", $var1);

    I think you meant sprintf("%.0f", $var1). Note the added '%'.

printf '%.0f', 1.5;  # works as you expect on perl 5.6.1 and up.

    Perhaps there is something else is affecting the value of
$var2.


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
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>


Reply via email to