@@ -314,9 +314,10 @@ static inline void bc_divide_copy_numerator(bc_num numerator, bc_num *num, size_
314
314
memcpy ((* num )-> n_value , numerator -> n_value , numerator -> n_len + scale );
315
315
}
316
316
317
- static inline void bc_divide_by_one (bc_num numerator , bc_num * quot , size_t quot_scale )
317
+ static inline void bc_divide_by_one (bc_num numerator , bc_num divisor , bc_num * quot , size_t quot_scale )
318
318
{
319
319
bc_divide_copy_numerator (numerator , quot , quot_scale );
320
+ (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
320
321
}
321
322
322
323
static inline void bc_divide_by_pow_10 (
@@ -360,8 +361,7 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
360
361
361
362
/* If divisor is 1 / -1, the quotient's n_value is equal to numerator's n_value. */
362
363
if (_bc_do_compare (divisor , BCG (_one_ ), divisor -> n_scale , false) == BCMATH_EQUAL ) {
363
- bc_divide_by_one (numerator , quot , quot_scale );
364
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
364
+ bc_divide_by_one (numerator , divisor , quot , quot_scale );
365
365
return true;
366
366
}
367
367
@@ -415,14 +415,14 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
415
415
} else {
416
416
* quot = bc_new_num_nonzeroed (1 , quot_scale ); /* 1 is for 0 */
417
417
}
418
+ (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
418
419
419
420
/* Size that can be read from numeratorptr */
420
421
size_t numerator_readable_size = numerator -> n_len + numerator -> n_scale - numerator_leading_zeros ;
421
422
422
423
/* If divisor is 1 here, return the result of adjusting the decimal point position of numerator. */
423
424
if (divisor_size == 1 && * divisorptr == 1 ) {
424
425
bc_divide_by_pow_10 (numeratorptr , numerator_readable_size , quot , quot_size , quot_scale );
425
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
426
426
return true;
427
427
}
428
428
@@ -436,8 +436,6 @@ bool bc_divide_ex(bc_num numerator, bc_num divisor, bc_num *quot, bc_num *rem, s
436
436
_bc_rm_leading_zeros (* quot );
437
437
if (bc_is_zero (* quot )) {
438
438
(* quot )-> n_sign = PLUS ;
439
- } else {
440
- (* quot )-> n_sign = numerator -> n_sign == divisor -> n_sign ? PLUS : MINUS ;
441
439
}
442
440
return true;
443
441
0 commit comments