my $float = shift; my $dec = shift; #### #!/usr/bin/perl use strict; use warnings; my $number = defined $ARGV[0] ? $ARGV[0] : 1.2549999999999999; my $places = defined $ARGV[1] ? $ARGV[1] : 2; printf "%.20f\n", $number; print round( $number , $places ), "\n"; sub round { my ($float, $decimals) = @_; my $int_leftShiftFloat = int( $float * 10**($decimals + 1) ); my $int_Round = int( ( $int_leftShiftFloat + 5 ) / 10 ); my $float_rightShiftInt = $int_Round / 10**$decimals; my $float_Result = $float_rightShiftInt; return $float_Result } #### 1.25499999999999990000 1.26