Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: erwan@xxxxxxxxxxxx (Erwan Lemonnier)
- Date: Wed, 18 Jul 2007 15:23:50 +0200
Hello folk!
Now I think I got a clean shot at what's troubling me 8-)
Consider the following code:
---------------------<snip>--------------------------
use strict;
use warnings;
use DBI;
my $ORASID = $ENV{ORACLE_SID};
my $ORAUSR = 'username';
my $ORAPWD = 'password';
sub showbin {
print "bin: ".unpack("B70",reverse pack("d",$_[0]))."\n";
}
my $v1 = "1.73696";
showbin($v1);
print "connecting\n";
my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );
my $v2 = "1.73696";
showbin($v2);
---------------------<snip>--------------------------
This code simply opens a connection toward an oracle database. And
shows the binary representation of the string "1.73696" converted into
a native float (NV) before and after we opened the connection.
When I run it with perl 5.6.2, DBI 1.38 and DBD::Oracle 1.17, it says:
[HEAD] ~/HEAD/test/t> !967$ /opt/perl-5.6.2/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010001
When I run it with perl 5.8.8, DBI 1.58 and DBD::Oracle 1.19, it says:
[HEAD] ~/HEAD/test/t> !969$ /opt/perl-5.8.8/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010000
See how the least significant bit (last one on the right) changes in
the last run?
There we have it. It is what caused the problems I have been spamming
you all with for the last few days :)
Conclusion: on my host (perl 5.8 etc.), the line:
my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );
seems to alter the way perl parses the string "1.73696". This later
resulted in arithmetic errors that looked like floating point related
issues but were not.
Has anyone any idea of what's happening here????
/Erwan
.
- Follow-Ups:
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Tim Bunce
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Jonathan Leffler
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- References:
- Re: Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Erwan Lemonnier
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Christopher Sarnowski
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Tim Bunce
- Re: float bug? perl 5.8, DBI and oracle 10.2.0
- From: Erwan Lemonnier
- Re: Re: float bug? perl 5.8, DBI and oracle 10.2.0
- Prev by Date: DBI::ORACLE
- Next by Date: Re: float bug? perl 5.8, DBI and oracle 10.2.0
- Previous by thread: Re: float bug? perl 5.8, DBI and oracle 10.2.0
- Next by thread: Re: float bug? perl 5.8, DBI and oracle 10.2.0
- Index(es):
Relevant Pages
|