Raskii
03-27-2001, 11:36 AM
I'm in the process of building an (simple) online quiz and I want the score (percentage) to only show to two or three decimals. Right now I'm using modulus to try and shave off the extra numbers like this:
$studentScore = ($studentScore + .0005) - ($studentScore % .001);
This didn't do anything so I decided to use bcmod():
$studentScore = bcmod($studentScore + .0005,.001);
When I do that, the parser tells me that I'm trying to divide by 0!
Does modulus in PHP only handle integers? If so, how can I chop off the extra digits?
$studentScore = ($studentScore + .0005) - ($studentScore % .001);
This didn't do anything so I decided to use bcmod():
$studentScore = bcmod($studentScore + .0005,.001);
When I do that, the parser tells me that I'm trying to divide by 0!
Does modulus in PHP only handle integers? If so, how can I chop off the extra digits?