cbits

package
v0.0.0-...-5564bc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add32

func Add32(x, y, carry uint32) (sum, carryOut uint32)

------------------------------------------------------------------------------ Add32 ------------------------------------------------------------------------------ Add32 returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1.

This function's execution time does not depend on the inputs.

func Div32

func Div32(hi, lo, y uint32) (quo, rem uint32)

------------------------------------------------------------------------------ Div32 ------------------------------------------------------------------------------ Div32 returns the quotient and remainder of (hi, lo) divided by y: quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper half in parameter hi and the lower half in parameter lo. Div32 panics for y == 0 (division by zero) or y <= hi (quotient overflow).

func Mul32

func Mul32(x, y uint32) (hi, lo uint32)

------------------------------------------------------------------------------ Mul32 ------------------------------------------------------------------------------ Mul32 returns the 64-bit product of x and y: (hi, lo) = x * y with the product bits' upper half returned in hi and the lower half returned in lo.

This function's execution time does not depend on the inputs.

func Rem32

func Rem32(hi, lo, y uint32) uint32

------------------------------------------------------------------------------ Rem32 ------------------------------------------------------------------------------ Rem32 returns the remainder of (hi, lo) divided by y. Rem32 panics for y == 0 (division by zero) but, unlike Div32, it doesn't panic on a quotient overflow.

func Sub32

func Sub32(x, y, borrow uint32) (diff, borrowOut uint32)

------------------------------------------------------------------------------ Sub32 ------------------------------------------------------------------------------ Sub32 returns the difference of x, y and borrow, diff = x - y - borrow. The borrow input must be 0 or 1; otherwise the behavior is undefined. The borrowOut output is guaranteed to be 0 or 1.

This function's execution time does not depend on the inputs.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL