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. Link to comment https://forums.phpfreaks.com/topic/144194-stop-number-rounding-updown/ 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. Link to comment https://forums.phpfreaks.com/topic/144194-stop-number-rounding-updown/#findComment-756694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.