in reply to return +0

In other contexts (which the use of NaN (not-a-number) suggests), +0 is a number. If it is defined in IEEE754 floating point arithmetic. (There is a -0 too).

So 10 / +0 is "positive infinity" and 10 / -0 is "negative infinity".

See http://en.wikipedia.org/wiki/Division_by_zero#Division_by_zero_in_computer_arithmetic for more gory details.

But - as others have noted - this probably does nothing in perl. (Although - can you overload unary plus? If so, someone might be doing something Too Clever.)

Replies are listed 'Best First'.
Re^2: return +0
by syphilis (Archbishop) on Nov 27, 2007 at 23:07 UTC
    There is a -0 too

    Signed zeroes exist in the mpfr library - and are therefore accessible to perl via Math::MPFR:
    C:\_32>perl -MMath::MPFR -e "$z=Math::MPFR->new(0);$z/=-1;print $z" -0
    They don't seem to be accessible via either Math::Pari or Math::BigFloat
    C:\_32>perl -MMath::Pari -e "$x=PARI(0);$x/=-1;print $x" 0 C:\_32>perl -MMath::BigFloat -e "$z=Math::BigFloat->new(0);$z/=-1;prin +t $z" 0
    can you overload unary plus?

    I don't think so. Even if you could, returning '+0' would not use the overloaded '+' subroutine - overloading works only with blessed objects (and 0 is not a blessed object :-)

    Cheers,
    Rob