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

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

Kevin Ryde
July 24, 2011 20:26
[perl #95530] BigRat int(-1/2) == 0
Message ID:
# New Ticket Created by  Kevin Ryde 
# Please include the string:  [perl #95530]
# in the subject line of all future correspondence about this issue. 
# <URL: >

[Please describe your issue here]

Applying int() to a BigRat -1/2 gives a value which is !=0.  The program 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. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About