Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Sorting Puzzle (just sort)

by imp (Priest)
on Feb 20, 2007 at 22:59 UTC ( #601231=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^3: Sorting Puzzle (just sort)
Re^4: Sorting Puzzle (just sort)
by jdporter (Canon) on Feb 21, 2007 at 00:41 UTC

    Well, thanks for playing obvious favorites... but please tell me what I said that was incorrect (other than insisting on bigint when some other module, such as Math::BigInt, might also do the job as well, as ysth pointed out). Seems to me that "for the numeric comparison to work properly" is unambiguous enough. Anyway, I'm not sure what you're arguing with, since I never claimed anything tye said (in this thread) was incorrect.

      I wasn't playing favorites actually. I had asked a very similar question shortly before you, and tye had corrected my assertion that perl wasn't comparing them numerically without 0+.

      His statement was technically correct that 0+ was not neccesary to force numeric comparison, as perl already did that. What 0+ accomplished was to force bigint's involvement. A minor, but valid point.

      As for reasons to avoid its use I'd guess the hidden cost of the bigint magic, and less than obvious cases where that magic doesn't come into play - such as in the original question.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://601231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-27 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls