php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch remove_scale_parameter_from_bcpowmod_bug44995 for BC math related Bug #44995

Patch version 2010-08-30 20:38 UTC

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

Developer: k.schroeder@php.net

Index: bcmath.c
===================================================================
--- bcmath.c	(Revision 302902)
+++ bcmath.c	(Arbeitskopie)
@@ -65,11 +65,10 @@
 	ZEND_ARG_INFO(0, right_operand)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bcpowmod, 0, 0, 3)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bcpowmod, 0, 0, 2)
 	ZEND_ARG_INFO(0, x)
 	ZEND_ARG_INFO(0, y)
 	ZEND_ARG_INFO(0, mod)
-	ZEND_ARG_INFO(0, scale)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_bcpow, 0, 0, 2)
@@ -399,17 +398,16 @@
 }
 /* }}} */
 
-/* {{{ proto string bcpowmod(string x, string y, string mod [, int scale])
+/* {{{ proto string bcpowmod(string x, string y, string mod)
    Returns the value of an arbitrary precision number raised to the power of another reduced by a modulous */
 PHP_FUNCTION(bcpowmod)
 {
 	char *left, *right, *modulous;
 	int left_len, right_len, modulous_len;
 	bc_num first, second, mod, result;
-	long scale = BCG(bc_precision);
 	int scale_int;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &left, &left_len, &right, &right_len, &modulous, &modulous_len) == FAILURE) {
 		return;
 	}
 
@@ -421,19 +419,16 @@
 	php_str2num(&second, right TSRMLS_CC);
 	php_str2num(&mod, modulous TSRMLS_CC);
 
-	scale_int = (int) ((int)scale < 0) ? 0 : scale;
+	scale_int = (int) 0;
 
 	if (bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC) != -1) {
-		if (result->n_scale > scale) {
-			result->n_scale = scale;
-		}
 		Z_STRVAL_P(return_value) = bc_num2str(result);
 		Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
 		Z_TYPE_P(return_value) = IS_STRING;
 	} else {
 		RETVAL_FALSE;
 	}
-	
+
 	bc_free_num(&first);
 	bc_free_num(&second);
 	bc_free_num(&mod);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC