I wrote a function to add commas and zeros to a number, if necessary, but I'm stuck in a module function. According to my PHP:
float(877.5) % 1 == 0 //true
Should not 877.5 % 1 == 0.5 ?
877.5 % 1 == 0.5
This gives you a reminder of what you need, fmod ,
fmod - returns the remainder with a floating point (modulo) of division of arguments
echo fmod(877.5, 1); // 0.5
No, the module operator tells you the rest of the division. Everything that is divided by 1 has no remainder, so it gives 0.
You can try your sample code from http://writecodeonline.com/php/
If you want to get only the decimal part, refer to What is the best way to get the fractional part of a float in PHP?
% will return only the remainder and everything that divides by 1, the reminder is always 0.