src/intobject/ops_pow

Source   Edit  

Procs

proc divmodNear(a, b: IntObject): tuple[q, r: IntObject] {....raises: [],
    tags: [RootEffect], forbids: [].}

_PyLong_DivmodNear.

where q is the nearest integer to the quotient a / b (the nearest even integer in the case of a tie) and r == a - q * b.

Hence q * b = a - r is the nearest multiple of b to a, preferring even multiples in the case of a tie.

This assumes b is positive.

Source   Edit  
proc pow(a, b: IntObject): IntObject {....raises: [ValueError], tags: [RootEffect],
                                       forbids: [].}
raises ValueError when b is negative Source   Edit  
proc pow(a: IntObject; b: Natural | SomeUnsignedInt): IntObject
Source   Edit  
proc pow[V, W, X: SomeIntegerOrObj](v: V; w: W; x: X): IntObject
Source   Edit  
proc powMod(v, w, x: IntObject): IntObject {....raises: [ValueError],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc powNatural(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
assuming b is Positive or zero (Natural) Source   Edit  
proc powPos(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
assuming b is Positive Source   Edit  
proc round(self: IntObject; oNdigits: SomeIntegerOrObj): IntObject
this is like Python's built-in round() for integers, which accepts an optional second argument ndigits.

If ndigits is negative, it rounds to the nearest multiple of 10**(-ndigits).
If two multiples are equally close, rounding is done toward the even choice.
Source   Edit