in reply to Re^5: NaNs are true
in thread NaNs are true

What happens if you add NaN to zero?

The usual rules apply. NaN+0 equals Nan, so ( 0 + $MPFR_NaN_obj ) returns a Math::MPFR object (courtesy of overloading of '+') that has a value of NaN, which is false.

Cheers,
Rob

Replies are listed 'Best First'.
Re^7: NaNs are true
by jdporter (Paladin) on Mar 01, 2011 at 03:49 UTC
    ... has a value of NaN, which is false.

    Ok, I'm confused. In your OP, you say NaNs are true. Now you're saying they're false.

    Update: I see, you're talking about your overloaded version, which changes the "sign" of NaN. Ok, I agree that changing that is a Bad Idea in general, because of the violation of expectations.

    So, I guess you'll be stuck (assuming you ditch your overloaded version) doing an explicit test for NaN...

    if ( $obj == NaN or $obj ) # true if true or NaN
    in which case, you could wrap it in a new method:
    sub isTrue # ! { my $obj = shift; $obj == NaN || $obj }