my $n = 114.9999999999999; print "$n\t", sprintf "%07d\n", $n; __END__ Output: 115 0000114