summaryrefslogtreecommitdiff
path: root/ext/bcmath/bcmath.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r--ext/bcmath/bcmath.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 1b91fba72f..f1e298b5cc 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -404,10 +404,16 @@ PHP_FUNCTION(bcpowmod)
php_str2num(&second, ZSTR_VAL(right));
php_str2num(&mod, ZSTR_VAL(modulus));
- if (bc_raisemod(first, second, mod, &result, scale) != -1) {
- RETVAL_STR(bc_num2str_ex(result, scale));
- } else {
- RETVAL_FALSE;
+ switch (bc_raisemod(first, second, mod, &result, scale)) {
+ case 0:
+ RETVAL_STR(bc_num2str_ex(result, scale));
+ break;
+ case -1:
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
+ break;
+ case -2:
+ zend_argument_value_error(2, "must be greater than 0");
+ break;
}
bc_free_num(&first);