F
Fabrice Baro
I'm trying to sort a hash whose values are exponential numbers.
foreach my $file (sort values %{$files{$brh}}){
print "$file\n";
}
prints:
0
1e-101
1e-103
1e-104
I've tried storing those numbers under regular notation by using
sprintf to convert: but it's impractical and seems not exact:
here are some of the numbers I obtain:
0.00[...]00000999999999999999957534737399913078515638562734891876822570107876
0.00[...]00010000000000000000015234388133035855383875390450151974382791625208
where the numbers should be 0.00[...]0001. Obviously there are some
conversion issues.
I think one solution could be to write a custom compare block or
function, but I'd rather use a builtin feature of sort. However I
haven't found such a feature in the perl FAQ nor in the groups.
foreach my $file (sort values %{$files{$brh}}){
print "$file\n";
}
prints:
0
1e-101
1e-103
1e-104
I've tried storing those numbers under regular notation by using
sprintf to convert: but it's impractical and seems not exact:
here are some of the numbers I obtain:
0.00[...]00000999999999999999957534737399913078515638562734891876822570107876
0.00[...]00010000000000000000015234388133035855383875390450151974382791625208
where the numbers should be 0.00[...]0001. Obviously there are some
conversion issues.
I think one solution could be to write a custom compare block or
function, but I'd rather use a builtin feature of sort. However I
haven't found such a feature in the perl FAQ nor in the groups.