|
Author |
Message |
Iyonix
WebHelper
Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England
|
Posted:
Mon Jan 20, 2003 5:15 pm (21 years, 3 months ago) |
|
I am dividing two variables by each other:
$ratio = $kills/$deaths;
and often I get a long decimal such as 2.45973184 How can I make it so that the decimal is correctly rounded to 2dp?
Thanks, |
________________________________ Iyonix |
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Mon Jan 20, 2003 5:31 pm (21 years, 3 months ago) |
|
Iyonix,
This should be of interest to you:
http://www.php.net/manual/en/function.round.php
http://www.php.net/manual/en/function.round.php wrote: | float round ( float val [, int precision])
Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). |
|
________________________________
|
|
|
|
Iyonix
WebHelper
Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England
|
Posted:
Mon Jan 20, 2003 5:39 pm (21 years, 3 months ago) |
|
Daniel wrote: | Iyonix,
This should be of interest to you:
http://www.php.net/manual/en/function.round.php
http://www.php.net/manual/en/function.round.php wrote: | float round ( float val [, int precision])
Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). |
|
Thank you very much Daniel. That is excactly what I needed |
________________________________ Iyonix |
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.23605 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |