[PHP] Rounding issue

2003-07-29 Thread Kevin Ison
I need to know if there is a work around for the following scenerio...

$x = 4.5012412;
echo round($x, 2); // results in 4.5 ---  however I want 4.50!  I want 2
decimal places!


Is there a way to keep the zero from being dropped?  I have not been able to
get the zero to stay there ... I realize this is the interpreters problem
but I need the zero.

thanks in advance

--
Kevin Ison
Charlotte, NC



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Rounding issue

2003-07-29 Thread Larry E . Ullman
$x = 4.5012412;
echo round($x, 2); // results in 4.5 ---  however I want 4.50!  I 
want 2
decimal places!
echo number_format ( round ($x, 2), 2);

Larry

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Rounding issue

2003-07-29 Thread Curt Zirzow
* Thus wrote Kevin Ison ([EMAIL PROTECTED]):
 I need to know if there is a work around for the following scenerio...
 
 $x = 4.5012412;
 echo round($x, 2); // results in 4.5 ---  however I want 4.50!  I want 2
 decimal places!


 
 
 Is there a way to keep the zero from being dropped?  I have not been able to
 get the zero to stay there ... I realize this is the interpreters problem
 but I need the zero.

number_format(round($x, 2),2);

you can always control with printf functions, but number format is
designed specifically for that.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Rounding issue

2003-07-29 Thread Kevin Ison
ahhh ok thanks guys!! That worked ... I knew it was something but I could
not remember which function...

thanks again!

Larry E . Ullman [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  $x = 4.5012412;
  echo round($x, 2); // results in 4.5 ---  however I want 4.50!  I
  want 2
  decimal places!

 echo number_format ( round ($x, 2), 2);

 Larry




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Rounding issue

2003-07-29 Thread Kevin Ison
ahhh ok thanks guys!! That worked ... I knew it was something but I could
not remember which function...

thanks again!

Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Kevin Ison ([EMAIL PROTECTED]):
  I need to know if there is a work around for the following scenerio...
 
  $x = 4.5012412;
  echo round($x, 2); // results in 4.5 ---  however I want 4.50!  I
want 2
  decimal places!


 
 
  Is there a way to keep the zero from being dropped?  I have not been
able to
  get the zero to stay there ... I realize this is the interpreters
problem
  but I need the zero.

 number_format(round($x, 2),2);

 you can always control with printf functions, but number format is
 designed specifically for that.


 Curt
 --
 I used to think I was indecisive, but now I'm not so sure.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php