Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Sorting Puzzle (just sort)

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

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

$a <=> $b already forces $a and $b to be interpretted as numbers, always.
It doesn't appear to with perl 5.8.2:
use strict; use warnings; my $d1 = '2007030110300020070301133000'; my $d2 = '2007030110300020070301143000'; printf "plain = %d\n", ($d1 <=> $d2); { use bigint; printf "bigint = %d\n", ($d1 <=> $d2); } { use bigint; printf "bigint-0 = %d\n", (($d1 -0)<=> ($d2-0)); }
plain = 0 bigint = 0 bigint-0 = -1

Replies are listed 'Best First'.
Re^3: Sorting Puzzle (just sort)
by tye (Sage) on Feb 20, 2007 at 22:31 UTC

    That doesn't show $d1 and $d2 being compared as not numbers and so doesn't contradict my point. I guess the other points are about getting bigint to magically turn numeric expressions into objects. I'm not a fan of such subtle magic and so didn't recommend the use of and see no real value for it here anyway. But thanks for indirectly clarifying those points.

    - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://601226]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2018-05-22 21:54 GMT
Find Nodes?
    Voting Booth?