Skip to content

Commit 03955d6

Browse files
committed
Added bc_divide_copy_numerator()
1 parent dfff6ac commit 03955d6

File tree

1 file changed

+8
-4
lines changed
  • ext/bcmath/libbcmath/src

1 file changed

+8
-4
lines changed

ext/bcmath/libbcmath/src/div.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,16 @@ static void bc_do_div(
300300
}
301301
}
302302

303+
static inline void bc_divide_copy_numerator(bc_num numerator, bc_num *num, size_t scale)
304+
{
305+
scale = MIN(numerator->n_scale, scale);
306+
*num = bc_new_num_nonzeroed(numerator->n_len, scale);
307+
memcpy((*num)->n_value, numerator->n_value, numerator->n_len + scale);
308+
}
309+
303310
static inline void bc_divide_by_one(bc_num numerator, bc_num *quot, size_t quot_scale)
304311
{
305-
quot_scale = MIN(numerator->n_scale, quot_scale);
306-
*quot = bc_new_num_nonzeroed(numerator->n_len, quot_scale);
307-
char *qptr = (*quot)->n_value;
308-
memcpy(qptr, numerator->n_value, numerator->n_len + quot_scale);
312+
bc_divide_copy_numerator(numerator, quot, quot_scale);
309313
}
310314

311315
static inline void bc_divide_by_pow_10(

0 commit comments

Comments
 (0)