develooper Front page | perl.perl5.porters | Postings from August 2014

[perl #122644] float sometimes behaves as integer

Thread Next
From:
Father Chrysostomos via RT
Date:
August 29, 2014 13:28
Subject:
[perl #122644] float sometimes behaves as integer
Message ID:
rt-4.0.18-17402-1409318914-426.122644-15-0@perl.org
On Fri Aug 29 03:42:57 2014, misch@czechin.cz wrote:
> 
> This is a bug report for perl from misch@czechin.cz,
> generated with the help of perlbug 1.39 running under perl 5.10.1.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Running script "t17" listed below produces this output:
> 
> $ ./t17
> x1=467.62
> x2=467.62
> x3=467
> 
> Values x1 and x2 are correct, but value x3 should be the same, but it
> isn't.
> This results in error in computations, because float "magically" under
> some circumstances changes to integer.
> 
> Problem is that this error is highly unpredictable.
> For example:
>   - with line "{} if $foo{x} <= 0;" commented out, script produces
> correct result "467.62"
>   - with line "X::y(%bar);" commented out, script produces correct
> result, too
>   - when I move content of "X.pm" directly into script "t17", script
> will also produce correct result
> 
> I suppose that problem lies somewhere between perl core, IV and NV
> representation of PV "467.62" value, and Tie::Hash.
> But alas, I am unable to debug this.
> 
> What puzzles me is the fact that even small change in script
> miraculously removes the bug.
> 
> Perl 5.8.8 was not affected by this bug.

I can confirm this bug is present at least from perl 5.8.9 to perl 5.14.4.  5.18.1 is fine.  (I don’t have 5.16 installed.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=122644

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About