-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storable Alters Floating Point Number? #15019
Comments
From eric@vertical-approach.comHi, I don't know if this is an issue with Storable or with Perl itself, but when I compare two identical floating points together, they compare correctly. However, when I freeze() and thaw() them, they do not. I am familiar with the dynamics of how floating points are stored, so that's not the issue. The issue is that Storable slightly alters an SvPVNV in a way that it doesn't compare like it used to. Here's the code (this is on Perl 5.18 and Storable 2.51): use 5.018001; my $a = nearest(.01,-656.8); my $c = thaw(freeze(\$a)); # here Storable alters the SvPVNV so that it compares incorrectly OUTPUT: EQUAL (NOTE: I know that '==' is unreliable for comparing floating point numbers, and that doing a nearest(.01,$a) eq nearest(.01,$b) is a more reliable way to solve this. Regardless, I still think this might be a bug folks would want addressed?) |
From zefram@fysh.orgmasterchiefaragorn wrote:
$c isn't the PVNV that you're interested in; it's a *reference to* a PVNV.
== is a perfectly good comparison operator. It's + and * and all those -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From eric@vertical-approach.comSo sorry...I mis-typed those last lines when submitting my simplified reproduction of this issue. Try out this snippet of code. It yields 'EQUAL' and then 'NOT EQUAL' on my Linux machine: use 5.018001; my $a = nearest(.01,-656.8); my $c = thaw(freeze(\$a)); # here Storable alters the SvPVNV so that it compares incorrectly |
From @tonycozOn Sun Nov 01 12:33:21 2015, eric@vertical-approach.com wrote:
This produces EQUAL on 5.20, but not because of a change in Storable, the fix was: commit b127e37 PATCH: [perl #108378] [perl #115800] Tony |
From eric@vertical-approach.comThanks for letting me know that's been fixed!! I've upgraded to 5.22.0, and I now also get: EQUAL Thanks. This ticket can be closed. |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#126502 (status was 'resolved')
Searchable as RT126502$
The text was updated successfully, but these errors were encountered: