php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53208
Patch C99_ZEND_patch_euclidean_modulo revision 2010-10-30 17:46 UTC by fibrefox at dynamicfiles dot de

Patch C99_ZEND_patch_euclidean_modulo for Documentation problem Bug #53208

Patch version 2010-10-30 17:46 UTC

Return to Bug #53208 | Download this patch
Patch Revisions:

Developer: fibrefox@dynamicfiles.de

--- C:/Users/FibreFoX/Desktop/php-5.2.14/Zend/zend_operators.c	Sat Jun 19 22:47:24 2010
+++ C:/Users/FibreFoX/Desktop/zend_operators.c	Sat Oct 30 19:39:15 2010
@@ -970,7 +970,9 @@
 	}
 
 	result->type = IS_LONG;
-	result->value.lval = op1->value.lval % op2->value.lval;
+
+	// c++ modulo is no true modulo, so here the true modulo-version (optimized) 
+	result->value.lval = (op1->value.lval < 0 ? ((op1->value.lval % op2->value.lval) + op2->value.lval) % op2->value.lval : op1->value.lval % op2->value.lval);
 	return SUCCESS;
 }
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 09:01:32 2024 UTC