#!/usr/bin/perl use strict; my @a; $a[0] = (0.1 - 0.1) * 10; #Should be 0 $a[1] = (0.2 - 0.1) * 10; #Should be 1 $a[2] = (0.3 - 0.1) * 10; #Should be 2 $a[3] = (0.4 - 0.1) * 10; #Should be 3 $a[4] = (0.5 - 0.1) * 10; #Should be 4 my $i; for( $i = 0; $i < 5; $i++ ) { print "$i: ", $a[$i], " ", int($a[$i]), "\n"; } print "\n"; for( $i = 0; $i < 5; $i++ ) { printf "%d: %s %d %f\n", $i, $a[$i], $a[$i], $a[$i]; } #### 0: 0 0 1: 1 1 2: 2 1 * 3: 3 3 4: 4 4 0: 0 0 0.000000 1: 1 1 1.000000 2: 2 1 2.000000 * 3: 3 3 3.000000 4: 4 4 4.000000