MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / DivInt

Method DivInt

extern/ttmath/ttmathint.h:523–559  ·  view source on GitHub ↗

! division this = this / ss2 (ss2 is int) returned values: 0 - ok 1 - division by zero for example: (result means 'this') 20 / 3 --> result: 6 remainder: 2 -20 / 3 --> result: -6 remainder: -2 20 / -3 --> result: -6 remainder: 2 -20 / -3 --> result: 6 remainder: -2 in other words: this(old) = ss2 * this(new)(result) + remainder */

Source from the content-addressed store, hash-verified

521 in other words: this(old) = ss2 * this(new)(result) + remainder
522 */
523 uint DivInt(sint ss2, sint * remainder = 0)
524 {
525 bool ss1_is_sign, ss2_is_sign;
526
527 ss1_is_sign = IsSign();
528
529 /*
530 we don't have to test the carry from Abs as well as in Mul
531 */
532 Abs();
533
534 if( ss2 < 0 )
535 {
536 ss2 = -ss2;
537 ss2_is_sign = true;
538 }
539 else
540 {
541 ss2_is_sign = false;
542 }
543
544 uint rem;
545 uint c = UInt<value_size>::DivInt((uint)ss2, &rem);
546
547 if( ss1_is_sign != ss2_is_sign )
548 SetSign();
549
550 if( remainder )
551 {
552 if( ss1_is_sign )
553 *remainder = -sint(rem);
554 else
555 *remainder = sint(rem);
556 }
557
558 return c;
559 }
560
561
562 uint DivInt(sint ss2, sint & remainder)

Callers 5

setScaleMethod · 0.45
divMethod · 0.45
operator/Method · 0.45
divModMethod · 0.45
I128limitMethod · 0.45

Calls 1

AbsFunction · 0.85

Tested by

no test coverage detected