Skip to content

Commit 130afcb

Browse files
committed
Changed bc_divide to bc_divide_ex, and changed three division functions to use it.
1 parent dd2ec85 commit 130afcb

File tree

5 files changed

+8
-97
lines changed

5 files changed

+8
-97
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
@@ -149,11 +149,7 @@ bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale);
149149

150150
bc_num bc_square(bc_num n1, size_t scale);
151151

152-
bool bc_divide(bc_num n1, bc_num n2, bc_num *quot, size_t scale);
153-
154-
bool bc_modulo(bc_num num1, bc_num num2, bc_num *resul, size_t scale);
155-
156-
bool bc_divmod(bc_num num1, bc_num num2, bc_num *quo, bc_num *rem, size_t scale);
152+
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);
157153

158154
bc_num bc_floor_or_ceil(bc_num num, bool is_floor);
159155

@@ -182,4 +178,9 @@ bool bc_sqrt(bc_num *num, size_t scale);
182178
#define bc_free_num(num) _bc_free_num_ex((num), 0)
183179
#define bc_num2str(num) bc_num2str_ex((num), (num->n_scale))
184180

181+
/* div and mod */
182+
#define bc_divide(n1, n2, quot, scale) bc_divide_ex((n1), (n2), (quot), NULL, (scale), true, false)
183+
#define bc_modulo(n1, n2, rem, scale) bc_divide_ex((n1), (n2), NULL, (rem), (scale), false, true)
184+
#define bc_divmod(n1, n2, quot, rem, scale) bc_divide_ex((n1), (n2), (quot), (rem), (scale), true, true)
185+
185186
#endif

ext/bcmath/libbcmath/src/div.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static inline void bc_divide_by_pow_10(
343343
}
344344
}
345345

346-
bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
346+
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)
347347
{
348348
/* divide by zero */
349349
if (bc_is_zero(divisor)) {

ext/bcmath/libbcmath/src/divmod.c

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

0 commit comments

Comments
 (0)