- I have the below Perl function to display up to two decimals places. It's not working when the input value is 2.01, and it gives the output as 2 instead of 2.01. I am not sure why it's rounding.
Instead of printf I wrote the output to a file, but still it gives me output1 as 2.
my $ramount = 2.01;
$ramount = int($ramount*100)/100;
printf "output1: $ramount";
- If I have values like .2, .23, .2345, 1,23, 23.1, and 9, what function can I use to pad zeros so that it displays 0.2, 0.23, 0.2345, 1, 23, 23.1, and 9?