use strict; use warnings; foreach (3.5, 2.6888, 8.25 ,8, 1249.7999999999999999) { printf("%.3f\n", $_); } __END__ 3.500 2.689 note <= rounding up from 2.6888 8.250 8.000 1249.800 <= note rounded up from 7999999999999