develooper Front page | perl.perl5.porters | Postings from July 2011

[perl #95530] BigRat int(-1/2) == 0

From:
Kevin Ryde
Date:
July 24, 2011 20:26
Subject:
[perl #95530] BigRat int(-1/2) == 0
Message ID:
rt-3.6.HEAD-7815-1311546152-166.95530-75-0@perl.org
# New Ticket Created by  Kevin Ryde 
# Please include the string:  [perl #95530]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=95530 >


-----------------------------------------------------------------
[Please describe your issue here]

Applying int() to a BigRat -1/2 gives a value which is !=0.  The program
foo.pl below prints

    Math::BigRat version 0.24
    oops, int==0 is false
    int+1==1 ok
    int stringize: "-0"
    int class: Math::BigInt

where I expected "oops, int==0 is false" to instead be "int==0 ok".

Looks like it comes out somehow as a negative zero bigint, where I take
it bigint doesn't normally have a negative zero.




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