|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-03-04 15:37 UTC] spam at michaelburri dot ch
Description: ------------ The fmod(dividend, divisor) function returns wrong values for negative dividends that are smaller than the divisor. For example -0.8 mod 6 => -1 * 6 + 5.2, so the result of the modulo (= remainder) is 5.2. Test script: --------------- <?php echo fmod(-0.8, 6); //Should return 5.2, but returns -0.8 ?> Expected result: ---------------- 5.2 Actual result: -------------- -0.8 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 20:00:01 2025 UTC |
Nope, it is correct. Read up on fmod and negative operands and you can try this simple C program: void main(int argc, char *argv[]) { printf("%f", fmod(-0.8,6)); }