src/intops/impl/intrinsics/gcc

Source   Edit  

GCC/Clang intrinsics-based implementations of arithmetic operations for integers.

Procs

func borrowingSub[T: SomeInteger](a, b: T; borrowIn: bool): (T, bool) {.inline,
    noinit.}
Source   Edit  
func builtinOverflowingAdd[T: SomeInteger](a, b: T; res: var T): bool {.
    importc: "__builtin_add_overflow", nodecl, ...raises: [], tags: [], forbids: [].}
Checks if a + b overflows. Returns true on overflow. Source   Edit  
func builtinOverflowingSub[T: SomeInteger](a, b: T; res: var T): bool {.
    importc: "__builtin_sub_overflow", nodecl, ...raises: [], tags: [], forbids: [].}
Checks if a - b overflows. Returns true on overflow. Source   Edit  
func carryingAdd[T: SomeInteger](a, b: T; carryIn: bool): (T, bool) {.inline,
    noinit.}
Source   Edit  
func overflowingAdd[T: SomeInteger](a, b: T): (T, bool) {.inline, noinit.}
Source   Edit  
func overflowingSub[T: SomeInteger](a, b: T): (T, bool) {.inline, noinit.}
Source   Edit  
func saturatingAdd[T: SomeSignedInt](a, b: T): T {.inline, noinit.}
Source   Edit  
func saturatingAdd[T: SomeUnsignedInt](a, b: T): T {.inline, noinit.}
Source   Edit  
func saturatingSub[T: SomeSignedInt](a, b: T): T {.inline, noinit.}
Source   Edit  
func saturatingSub[T: SomeUnsignedInt](a, b: T): T {.inline, noinit.}
Source   Edit