Posted by aaron.reese on 09/11/06 15:33
multiply by 100
convert to integer (drop decimals)
divide by 100
Kim André Akerø wrote:
> wesley@ispace.co.za wrote:
>
> > Hi all
> > I have a floating point number stored in a variable. i want to round
> > that number off to two places and store it in a variable. Does anyone
> > know how to do that?
> > I know that i can use the printf to display the number to 2 decimal
> > places. but i want to store that number in a vaiable.
>
> How about this:
> $value = 3.1415926535897932384626433832795;
> $value = round($value, 2);
>
> http://no.php.net/round
>
> --
> Kim André Akerø
> - kimandre@NOSPAMbetadome.com
> (remove NOSPAM to contact me directly)
Navigation:
[Reply to this message]
|