Next: , Previous: , Up: Arithmetic on poly_ints   [Contents][Index]


10.4.3 Division of poly_ints

Division of poly_ints is possible for certain inputs. The functions for division return true if the operation is possible and in most cases return the results by pointer. The routines are:

multiple_p (a, b)
multiple_p (a, b, &quotient)

Return true if a is an exact multiple of b, storing the result in quotient if so. There are overloads for various combinations of polynomial and constant a, b and quotient.

constant_multiple_p (a, b)
constant_multiple_p (a, b, &quotient)

Like multiple_p, but also test whether the multiple is a compile-time constant.

can_div_trunc_p (a, b, &quotient)
can_div_trunc_p (a, b, &quotient, &remainder)

Return true if we can calculate ‘trunc (a / b)’ at compile time, storing the result in quotient and remainder if so.

can_div_away_from_zero_p (a, b, &quotient)

Return true if we can calculate ‘a / b’ at compile time, rounding away from zero. Store the result in quotient if so.

Note that this is true if and only if can_div_trunc_p is true. The only difference is in the rounding of the result.

There is also an asserting form of division:

exact_div (a, b)

Assert that a is a multiple of b and return ‘a / b’. The result is a poly_int if a is a poly_int.