Re: Limiting floats

by John Erjavec V <jev(at)>

 Date:  Sat, 07 Oct 2000 00:49:56 -0500
 To:  John Starkey <jstarkey(at)>,
  todo: View Thread, Original
At 04:53 PM 10/5/00 -0600, John Starkey wrote:
>Can someone tell me what I have to do to limit a float down to 2 decimal
>points. I'm trying to average user input and display the results.

Well, that would depend on which language you are using to do this.  In 
Perl or C, I would use the printf function to print out the variable, like 
so (with Perl syntax):

printf("The value is %0.2f.\n", $value); # Where $value contains 2.1175
# Prints 'The value is 2.12.' without the quotes.


John Erjavec V  ##  spammers-will-be-reported(at)
"I'll say it again for the logic impaired."  --Larry Wall

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA