4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP: Decimal Places
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Iyonix
WebHelper
WebHelper


Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England

PostPosted: Mon Jan 20, 2003 5:15 pm (14 years, 9 months ago) Reply with QuoteBack to Top

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
OfflineView User's ProfileFind all posts by IyonixSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Jan 20, 2003 5:31 pm (14 years, 9 months ago) Reply with QuoteBack to Top

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).

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Iyonix
WebHelper
WebHelper


Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England

PostPosted: Mon Jan 20, 2003 5:39 pm (14 years, 9 months ago) Reply with QuoteBack to Top

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 Very Happy

________________________________
Iyonix
OfflineView User's ProfileFind all posts by IyonixSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




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.078946 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme