in reply to Re: Sorting Puzzle (just sort)
in thread Sorting Puzzle

The notes about ... having to use "0+" to force numeric interpretation make no sense to me

I'm not saying it makes sense to me, either. But the perl interpreter don't lie, if you get my drift. You have to do both things (use bigint and manually coerce the numeric conversion) for the numeric comparison to work properly. Try it yourself if you don't believe me.

This is perl, v5.8.8 built for MSWin32-x86-multi-thread

Binary build 819 [267479] provided by ActiveState 
Built Aug 29 2006 12:42:41
A word spoken in Mind will reach its own level, in the objective world, by its own weight

Replies are listed 'Best First'.
Re^3: Sorting Puzzle (just sort)
by imp (Priest) on Feb 20, 2007 at 22:59 UTC
    Tye's statement was correct. Perl does indeed compare the two values numerically, but the magic of bigint is not triggered. The 0+ doesn't force numeric comparison in this case, it triggers bigint magic.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^3: Sorting Puzzle (just sort)
by ysth (Canon) on Feb 20, 2007 at 23:34 UTC
    But why would you recommend bigint rather than Math::BigInt in this case???

      I have no reason; I grabbed the first one I found. If other "big math" modules work as well, great!

        bigint is a viral make-everything-a-Math::BigInt layer for Math::BigInt; if you don't want that (and usually you don't), selectively using Math::BigInt->new('string-of-digits') to get an overloaded object is a lot less intrusive.