in reply to math with decimals

Do you mean it doesn't display trailing zeroes in the decimals? You can add them using sprintf:

$num = 64; $num = sprintf('%.2f', $num); print($num, "\n"); # Prints 64.00

Note that %f rounds:

$num = 123.456; $num = sprintf('%.2f', $num); print($num, "\n"); # Prints 123.46

Replies are listed 'Best First'.
Re^2: math with decimals
by GrandFather (Saint) on Nov 24, 2005 at 00:51 UTC

    or just use printf:

    printf "%.2f %.2f\n", 1.25 + 805.75, 64 * 35.55;

    Prints:

    807.00 2275.20

    DWIM is Perl's answer to Gödel