70 return (negA && !negB) || (!negA && negB);
78 cairo_uint128_t result = Umul (a, b);
83 int64x64_t::Umul (
const cairo_uint128_t a,
const cairo_uint128_t b)
85 cairo_uint128_t result;
86 cairo_uint128_t hiPart, loPart, midPart;
87 cairo_uint128_t res1, res2;
101 "High precision 128 bits multiplication error: multiplication overflow.");
121 cairo_uint128_t a, b;
123 cairo_uint128_t result = Udiv (a, b);
128 int64x64_t::Udiv (
const cairo_uint128_t a,
const cairo_uint128_t b)
130 cairo_uint128_t den = b;
132 cairo_uint128_t result = qr.
quo;
133 cairo_uint128_t rem = qr.
rem;
136 const uint64_t DIGITS = 64;
140 "Remainder not less than divisor");
146 while ( (shift < DIGITS) && !(den.lo & 0x1))
155 while ( (digis + shift < DIGITS) &&
156 !(rem.hi & HPCAIRO_MASK_HI_BIT) )
166 while ( (digis + shift < DIGITS) &&
186 shift = DIGITS - digis;
194 int64x64_t::MulByInvert (
const int64x64_t & o)
198 cairo_uint128_t result = UmulByInvert (a, o._v);
204 int64x64_t::UmulByInvert (
const cairo_uint128_t a,
const cairo_uint128_t b)
206 cairo_uint128_t result;
207 cairo_uint128_t hi, mid;
218 int64x64_t::Invert (
const uint64_t v)
221 cairo_uint128_t a, factor;
227 result._v = Udiv (a, factor);
229 tmp.MulByInvert (result);
230 if (tmp.GetHigh () != 1)
232 cairo_uint128_t one = { 1, 0};
cairo_uint128_t I _cairo_uint64_to_uint128(cairo_uint64_t i)
High precision numerical type, implementing Q64.64 fixed precision.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
cairo_uint128_t I _cairo_uint128_negate(cairo_uint128_t a)
int I _cairo_uint128_eq(cairo_uint128_t a, cairo_uint128_t b)
Definition of the testing macros and declaration of the testing classes.
cairo_uquorem128_t I _cairo_uint128_divrem(cairo_uint128_t num, cairo_uint128_t den)
Implementation of the cairo_x functions which implement high precision arithmetic.
int I _cairo_uint128_lt(cairo_uint128_t a, cairo_uint128_t b)
cairo_uint128_t I _cairo_uint128_rsl(cairo_uint128_t a, int shift)
cairo_uint128_t I _cairo_uint32_to_uint128(uint32_t i)
cairo_uint128_t I _cairo_uint64x64_128_mul(cairo_uint64_t a, cairo_uint64_t b)
Definition of assertion macros NS_ASSERT() and NS_ASSERT_MSG().
cairo_uint128_t I _cairo_uint128_lsl(cairo_uint128_t a, int shift)
#define _cairo_int128_negative(a)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define _cairo_int128_lsl(a, b)
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define _cairo_int128_negate(a)
#define _cairo_int128_to_uint128(i)
cairo_uint128_t I _cairo_uint128_add(cairo_uint128_t a, cairo_uint128_t b)
NS_ABORT_x macro definitions.
static bool output_sign(const int128_t sa, const int128_t sb, uint128_t &ua, uint128_t &ub)
Compute the sign of the result of multiplying or dividing Q64.64 fixed precision operands.