@@ -309,9 +309,10 @@ static inline void bc_divide_copy_numerator(bc_num numerator, bc_num *num, size_
309
309
memcpy ((* num )-> n_value , numerator -> n_value , numerator -> n_len + scale );
310
310
}
311
311
312
- static inline void bc_divide_by_one (bc_num numerator , bc_num * quot , size_t quot_scale )
312
+ static inline void bc_divide_by_one (bc_num numerator , bc_num divisor , bc_num * quot , size_t quot_scale )
313
313
{
314
314
bc_divide_copy_numerator (numerator , quot , quot_scale );
315
+ (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
315
316
}
316
317
317
318
static inline void bc_divide_by_pow_10 (
@@ -355,8 +356,7 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
355
356
356
357
/* If divisor is 1 / -1, the quotient's n_value is equal to numerator's n_value. */
357
358
if (_bc_do_compare (divisor , BCG (_one_ ), divisor -> n_scale , false) == BCMATH_EQUAL ) {
358
- bc_divide_by_one (numerator , quot , quot_scale );
359
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
359
+ bc_divide_by_one (numerator , divisor , quot , quot_scale );
360
360
return true;
361
361
}
362
362
@@ -404,14 +404,14 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
404
404
} else {
405
405
* quot = bc_new_num_nonzeroed (1 , quot_scale ); /* 1 is for 0 */
406
406
}
407
+ (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
407
408
408
409
/* Size that can be read from numeratorptr */
409
410
size_t numerator_readable_size = numerator -> n_len + numerator -> n_scale - numerator_leading_zeros ;
410
411
411
412
/* If divisor is 1 here, return the result of adjusting the decimal point position of numerator. */
412
413
if (divisor_size == 1 && * divisorptr == 1 ) {
413
414
bc_divide_by_pow_10 (numeratorptr , numerator_readable_size , quot , quot_size , quot_scale );
414
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
415
415
return true;
416
416
}
417
417
@@ -425,9 +425,6 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
425
425
_bc_rm_leading_zeros (* quot );
426
426
if (bc_is_zero (* quot )) {
427
427
(* quot )-> n_sign = PLUS ;
428
- (* quot )-> n_scale = 0 ;
429
- } else {
430
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
431
428
}
432
429
return true;
433
430
0 commit comments