src/intobject/ops_divmod

Source   Edit  

Types

SomeUnsignedIntSmallerThanTwoDigits = uint8 | uint16 | Digit
Source   Edit  

Procs

proc `%`(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
                                       forbids: [].}
Note: this may raises DivByZeroDefect
Source   Edit  
proc `//`(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
                                        forbids: [].}
Note: this may raises DivByZeroDefect
Source   Edit  
proc ceilDiv(a, b: IntObject): IntObject {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `div`(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Note: this raises DivByZeroDefect when b is zero
Source   Edit  
proc divmod(a, b: IntObject): tuple[d, m: IntObject] {....raises: [],
    tags: [RootEffect], forbids: [].}
Note: this is Python's divmod(get division and modulo), ref proc divrem(IntObject, IntObject) for Nim's std/math divmod
Hint: this raises DivByZeroDefect when b is zero
Source   Edit  
proc divmodNonZero(a, b: IntObject): tuple[d, m: IntObject] {....raises: [],
    tags: [RootEffect], forbids: [].}
export for builtins.divmod Source   Edit  
proc divRem(a: IntObject; n: Digit; remainder: var Digit): IntObject {.
    ...raises: [], tags: [], forbids: [].}

divRem1. Divide an integer by a single digit, returning both quotient and remainder The sign of a is ignored; n should not be zero.

the result's sign is always positive

Source   Edit  
proc divrem(a, b: IntObject): tuple[d, r: IntObject] {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc floordiv(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Note: this raises DivByZeroDefect when b is zero
Source   Edit  
proc floordivNonZero(a, b: IntObject): IntObject {....raises: [],
    tags: [RootEffect], forbids: [].}

Integer division

assuming b is non-zero

Source   Edit  
proc floormod(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Note: this raises DivByZeroDefect when b is zero
Source   Edit  
proc floormodNonZero(a, b: IntObject): IntObject {....raises: [],
    tags: [RootEffect], forbids: [].}

Integer division

assuming b is non-zero

Source   Edit  
proc `mod`(a, b: IntObject): IntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Note: this raises DivByZeroDefect when b is zero
Source   Edit  
proc `mod`(a: IntObject; n: TwoDigits): IntObject {....raises: [], tags: [],
    forbids: [].}
rem1 Get the remainder of an integer divided by a single digit. The sign of a is ignored; n should not be zero.
Hint: Other mixin ops against fixed-width integer are implemented in ops_mix_nim.nim
Source   Edit