SirChick Posted October 3, 2007 Share Posted October 3, 2007 I have a script which goes something like this: user in puts a number lets say 2. This multiplied by 5 to make 10. Then a sum of two float format numbers are added together.. this equals = $totalpercentage In the user's details i got "total" and what happens is i got a sum that does: 10 * 1 + $totalpercentage/100 this is then added on to the "total" But now out of completely rare chances i hit a situation which created a result of: 1 Self Defence Sessions giving you a defence gain of 4.99999999999E-5. I'm assuming that means its a reoccuring result...is there a way i can round off the value to 4.99999999999 when ever such a reoccuring result appears? Quote Link to comment https://forums.phpfreaks.com/topic/71609-reoccuring-number/ Share on other sites More sharing options...
wtmh144 Posted October 3, 2007 Share Posted October 3, 2007 I don't know if you can round it to 4.9999... But you could use a simple round() function to round it to 5. Quote Link to comment https://forums.phpfreaks.com/topic/71609-reoccuring-number/#findComment-360541 Share on other sites More sharing options...
dbillings Posted October 3, 2007 Share Posted October 3, 2007 http://us2.php.net/manual/en/ref.math.php Quote Link to comment https://forums.phpfreaks.com/topic/71609-reoccuring-number/#findComment-360544 Share on other sites More sharing options...
SirChick Posted October 3, 2007 Author Share Posted October 3, 2007 Do you know which reference i should be taking a look at.. i looked at the Is Infinite but its talking about strings that have INF at the end of the string which mine does not... so not sure if thats what im meant to be looking at ? Quote Link to comment https://forums.phpfreaks.com/topic/71609-reoccuring-number/#findComment-360553 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.