Jump to content

Stop number rounding up/down


only1perky

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.