Edit report at https://bugs.php.net/bug.php?id=64350&edit=1
ID: 64350 Updated by: ras...@php.net Reported by: spam at michaelburri dot ch Summary: fmod returning wrong values for negative dividends -Status: Open +Status: Not a bug Type: Bug Package: Math related Operating System: OS X 10.8.2 (12C3012) PHP Version: 5.4Git-2013-03-04 (Git) Block user comment: N Private report: N New Comment: 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)); } Previous Comments: ------------------------------------------------------------------------ [2013-03-04 15:37:42] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64350&edit=1