That is because you don't use printf/ sprintf. Printf/sprintf helps you handle this
thing
correctly. Try executing the following code:
********************************************************************************************
#!/usr/bin/perl -w
use strict;
my $x=1.999999999999999999999;
my $y=sprintf("%3.2f",$x);
print "$y\n";
*******************************************************************************************
The result will be "2.0".
Herzliche Gruessen.
On 2003.12.03 05:54, Stefan Jahnke wrote:
> Hi list
>
> In PL/SQL, 174413 - 169281.6 (as FLOAT) results in 5131.4 as it should.
> In Perl, it results in 5131.39999999999. In C++ (GCC on both Linux and MS
> Windows) it results in 5131.4.
> I find it pretty irritating that perl doesn't handle that correctly.
> I know, it's always a problem with floating point arithmetics, but how is
> it, that perl already says good bye to accurate results while PL/SQL and C
> both still give the correct result ?
> Is there any work around or something I have to consider when doing floating
> point arithmetics in Perl ?
> I need to have accurate values without rounding them for statistic
> calculations.
>
> TIA,
> Stefan
>
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> --
> Author: Stefan Jahnke
> INET: [EMAIL PROTECTED]
>
> Fat City Network Services -- 858-538-5051 http://www.fatcity.com
> San Diego, California -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
--
Mladen Gogala
Oracle DBA
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Mladen Gogala
INET: [EMAIL PROTECTED]
Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).