only1perky Posted February 7, 2009 Share Posted February 7, 2009 Hi Guys, I have a voting script on my site which works alright and stores total votes and the total value in the database. I am now trying to work out the average of the votes using: $average = $totalvalue / $totalvotes; This kind of works but when $average is inserted into the database (float 5,2 by the way) is automatically rounds up or down. For example $totalvalue = 7 $totalvotes = 2 The average I would like to be displayed is 3.5 but it is storing 4.00. Am I missing something obvious? Please help. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 7, 2009 Share Posted February 7, 2009 check precision in your php.ini file i am guessing it is set to zero or add ini_set("precision",14); to the top of your script (14 is the default value) Scott. Quote Link to comment 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.