in reply to place floats into array

Using sprintf:

use strict; use warnings; my @num = qw[ 1.3e-3 3.7e-5 102 46 1e-4 1e-12 ]; my @a; my $base; for (sort {$b <=> $a} @num) { my ($i) = sprintf('%e', $_) =~ /([-+]\d+)/; $base //= $i; $a[$base - $i] = $_; } say $_ // 0 for @a;

Results:

102 46 0 0 0 1.3e-3 1e-4 3.7e-5 0 0 0 0 0 0 1e-12