Skip to content

Commit b2c1b3f

Browse files
committed
Changed bc_divide to bc_divide_ex, and changed three division functions to use it.
1 parent aaf1f6a commit b2c1b3f

File tree

5 files changed

+8
-98
lines changed

5 files changed

+8
-98
lines changed

ext/bcmath/config.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ if test "$PHP_BCMATH" != "no"; then
1010
libbcmath/src/compare.c
1111
libbcmath/src/convert.c
1212
libbcmath/src/div.c
13-
libbcmath/src/divmod.c
1413
libbcmath/src/doaddsub.c
1514
libbcmath/src/floor_or_ceil.c
1615
libbcmath/src/long2num.c

ext/bcmath/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG_ENABLE("bcmath", "bc style precision math functions", "yes");
55
if (PHP_BCMATH == "yes") {
66
EXTENSION("bcmath", "bcmath.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
77
ADD_SOURCES("ext/bcmath/libbcmath/src", "add.c div.c init.c neg.c \
8-
raisemod.c sub.c compare.c divmod.c int2num.c long2num.c \
8+
raisemod.c sub.c compare.c int2num.c long2num.c \
99
num2long.c recmul.c sqrt.c zero.c doaddsub.c \
1010
floor_or_ceil.c nearzero.c num2str.c raise.c rmzero.c str2num.c \
1111
round.c convert.c", "bcmath");

ext/bcmath/libbcmath/src/bcmath.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale);
147147
*(result) = mul_ex; \
148148
} while (0)
149149

150-
bool bc_divide(bc_num n1, bc_num n2, bc_num *quot, size_t scale);
151-
152-
bool bc_modulo(bc_num num1, bc_num num2, bc_num *resul, size_t scale);
153-
154-
bool bc_divmod(bc_num num1, bc_num num2, bc_num *quo, bc_num *rem, size_t scale);
150+
bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, size_t scale, bool use_quot, bool use_rem);
155151

156152
bc_num bc_floor_or_ceil(bc_num num, bool is_floor);
157153

@@ -188,4 +184,9 @@ bool bc_sqrt(bc_num *num, size_t scale);
188184
#define bc_free_num(num) _bc_free_num_ex((num), 0)
189185
#define bc_num2str(num) bc_num2str_ex((num), (num->n_scale))
190186

187+
/* div and mod */
188+
#define bc_divide(n1, n2, quot, scale) bc_divide_ex((n1), (n2), (quot), NULL, (scale), true, false)
189+
#define bc_modulo(n1, n2, rem, scale) bc_divide_ex((n1), (n2), NULL, (rem), (scale), false, true)
190+
#define bc_divmod(n1, n2, quot, rem, scale) bc_divide_ex((n1), (n2), (quot), (rem), (scale), true, true)
191+
191192
#endif

ext/bcmath/libbcmath/src/div.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static inline void bc_divide_by_pow_10(
338338
}
339339
}
340340

341-
bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
341+
bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, size_t scale, bool use_quot, bool use_rem)
342342
{
343343
/* divide by zero */
344344
if (bc_is_zero(divisor)) {

ext/bcmath/libbcmath/src/divmod.c

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)