Skip to content

Commit bc2ebf9

Browse files
committed
If the result is 0, n_scale is set to 0.
1 parent fa1effd commit bc2ebf9

File tree

5 files changed

+5
-0
lines changed

5 files changed

+5
-0
lines changed

ext/bcmath/libbcmath/src/div.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
430430
_bc_rm_leading_zeros(*quot);
431431
if (bc_is_zero(*quot)) {
432432
(*quot)->n_sign = PLUS;
433+
(*quot)->scale = 0;
433434
} else {
434435
(*quot)->n_sign = numerator->n_sign == divisor->n_sign ? PLUS : MINUS;
435436
}

ext/bcmath/libbcmath/src/divmod.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ bool bc_divmod(bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, size_t scale
7474
(*rem)->n_scale = MIN(scale, (*rem)->n_scale);
7575
if (bc_is_zero(*rem)) {
7676
(*rem)->n_sign = PLUS;
77+
(*rem)->n_scale = 0;
7778
}
7879

7980
return true;

ext/bcmath/libbcmath/src/floor_or_ceil.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ bc_num bc_floor_or_ceil(bc_num num, bool is_floor)
5555
check_zero:
5656
if (bc_is_zero(result)) {
5757
result->n_sign = PLUS;
58+
result->n_scale = 0;
5859
}
5960

6061
return result;

ext/bcmath/libbcmath/src/recmul.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale)
264264
_bc_rm_leading_zeros(prod);
265265
if (bc_is_zero(prod)) {
266266
prod->n_sign = PLUS;
267+
prod->n_scale = 0;
267268
}
268269
return prod;
269270
}

ext/bcmath/libbcmath/src/round.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,6 @@ void bc_round(bc_num num, zend_long precision, zend_long mode, bc_num *result)
224224
check_zero:
225225
if (bc_is_zero(*result)) {
226226
(*result)->n_sign = PLUS;
227+
(*result)->n_scale = 0;
227228
}
228229
}

0 commit comments

Comments
 (0)