Trac Ticket #370 (NaN/Inf Rounding)

Patrick R. Michaud pmichaud at pobox.com
Tue Feb 24 17:54:57 UTC 2009


On Tue, Feb 24, 2009 at 06:43:01PM +0100, NotFound wrote:
> > 3) If this really isn't a Parrot bug, could someone point me to where
> > in the Rakudo/Parrot linkage this bug lives?
> 
> I suppose that if someone already knows that, the bug will be already fixed ;)

FWIW, I don't entirely agree with the premise that this is
strictly a Rakudo bug.  I find that Parrot has some undefined 
behavior when dealing with NaN, Inf, and integers, and little 
documentation to indicate what the expected behavior (if any) 
should be.  As an example:

    $ cat x.pir
    .sub 'main'
        $N0 = 3.5
        say $N0
        $I0 = floor $N0
        say $I0
    
        $N0 = 'Inf'
        say $N0
        $I0 = floor $N0
        say $I0
    .end
    
    $ ./parrot x.pir
    3.5
    3
    Inf
    -2147483648
    $

On my machine, Parrot seems to always treat an integer
conversion of any infinity as -2147483648.  Better would
seem to be to throw a range exception or the like, instead
of silently converting to a non-infinite integer value.

Pm


More information about the parrot-dev mailing list