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:
Output: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 |