in reply to decimal point

You want to take a look at printf. I believe the specific format you are looking for is "%0.2f"


UPDATE:I accidentally said 0.2d, I meant 0.2f but already clicked on submit. Thought I could fix it before anybody saw it, but ovid was too fast for me. :)

Replies are listed 'Best First'.
(Ovid) Re(2): decimal point
by Ovid (Cardinal) on Feb 12, 2002 at 19:07 UTC

    Close. %0.2f.

    perl -e '$x=80.03723;printf "%0.2f", $x'

    Cheers,
    Ovid

    Update: For those who may be confused, ehdonhon originally had "%0.2d", instead of "%0.2f". My reply looks a bit odd without that context.

    Update 2: It seems I made my original post before ehdonhon fixed /h(is|er)/ node. Then, I made made my update before seeing ehdonhon's update, thus, my update looks confusing in light of the other update. Sigh. I guess we'll play ping-pong with the updates :)

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.