bits

Imports

Imports #

_ "unsafe"

Constants & Variables

UintSize const #

UintSize is the size of a uint in bits.

const UintSize = uintSize

deBruijn32 const #

See http://keithandkatie.com/keith/papers/debruijn.html

const deBruijn32 = 0x077CB531

deBruijn32tab var #

var deBruijn32tab = [32]byte{...}

deBruijn64 const #

const deBruijn64 = 0x03f79d71b4ca8b09

deBruijn64tab var #

var deBruijn64tab = [64]byte{...}

divideError var #

go:linkname divideError runtime.divideError

var divideError error

divideError var #

var divideError = *ast.CallExpr

len8tab const #

const len8tab = *ast.BinaryExpr

m0 const #

const m0 = 0x5555555555555555

m1 const #

const m1 = 0x3333333333333333

m2 const #

const m2 = 0x0f0f0f0f0f0f0f0f

m3 const #

const m3 = 0x00ff00ff00ff00ff

m4 const #

const m4 = 0x0000ffff0000ffff

ntz8tab const #

const ntz8tab = *ast.BinaryExpr

overflowError var #

var overflowError = *ast.CallExpr

overflowError var #

go:linkname overflowError runtime.overflowError

var overflowError error

pop8tab const #

const pop8tab = *ast.BinaryExpr

rev8tab const #

const rev8tab = *ast.BinaryExpr

uintSize const #

const uintSize = *ast.BinaryExpr

Type Aliases

errorString type #

type errorString string

Functions

Add function #

Add 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 Add(x uint, y uint, carry uint) (sum uint, carryOut uint)

Add32 function #

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 Add32(x uint32, y uint32, carry uint32) (sum uint32, carryOut uint32)

Add64 function #

Add64 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 Add64(x uint64, y uint64, carry uint64) (sum uint64, carryOut uint64)

Div function #

Div 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. Div panics for y == 0 (division by zero) or y <= hi (quotient overflow).

func Div(hi uint, lo uint, y uint) (quo uint, rem uint)

Div32 function #

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 Div32(hi uint32, lo uint32, y uint32) (quo uint32, rem uint32)

Div64 function #

Div64 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. Div64 panics for y == 0 (division by zero) or y <= hi (quotient overflow).

func Div64(hi uint64, lo uint64, y uint64) (quo uint64, rem uint64)

Error method #

func (e errorString) Error() string

LeadingZeros function #

LeadingZeros returns the number of leading zero bits in x; the result is [UintSize] for x == 0.

func LeadingZeros(x uint) int

LeadingZeros16 function #

LeadingZeros16 returns the number of leading zero bits in x; the result is 16 for x == 0.

func LeadingZeros16(x uint16) int

LeadingZeros32 function #

LeadingZeros32 returns the number of leading zero bits in x; the result is 32 for x == 0.

func LeadingZeros32(x uint32) int

LeadingZeros64 function #

LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0.

func LeadingZeros64(x uint64) int

LeadingZeros8 function #

LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0.

func LeadingZeros8(x uint8) int

Len function #

Len returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func Len(x uint) int

Len16 function #

Len16 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func Len16(x uint16) (n int)

Len32 function #

Len32 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func Len32(x uint32) (n int)

Len64 function #

Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func Len64(x uint64) (n int)

Len8 function #

Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func Len8(x uint8) int

Mul function #

Mul returns the full-width 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 Mul(x uint, y uint) (hi uint, lo uint)

Mul32 function #

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 Mul32(x uint32, y uint32) (hi uint32, lo uint32)

Mul64 function #

Mul64 returns the 128-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 Mul64(x uint64, y uint64) (hi uint64, lo uint64)

OnesCount function #

OnesCount returns the number of one bits ("population count") in x.

func OnesCount(x uint) int

OnesCount16 function #

OnesCount16 returns the number of one bits ("population count") in x.

func OnesCount16(x uint16) int

OnesCount32 function #

OnesCount32 returns the number of one bits ("population count") in x.

func OnesCount32(x uint32) int

OnesCount64 function #

OnesCount64 returns the number of one bits ("population count") in x.

func OnesCount64(x uint64) int

OnesCount8 function #

OnesCount8 returns the number of one bits ("population count") in x.

func OnesCount8(x uint8) int

Rem function #

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

func Rem(hi uint, lo uint, y uint) uint

Rem32 function #

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 Rem32(hi uint32, lo uint32, y uint32) uint32

Rem64 function #

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

func Rem64(hi uint64, lo uint64, y uint64) uint64

Reverse function #

Reverse returns the value of x with its bits in reversed order.

func Reverse(x uint) uint

Reverse16 function #

Reverse16 returns the value of x with its bits in reversed order.

func Reverse16(x uint16) uint16

Reverse32 function #

Reverse32 returns the value of x with its bits in reversed order.

func Reverse32(x uint32) uint32

Reverse64 function #

Reverse64 returns the value of x with its bits in reversed order.

func Reverse64(x uint64) uint64

Reverse8 function #

Reverse8 returns the value of x with its bits in reversed order.

func Reverse8(x uint8) uint8

ReverseBytes function #

ReverseBytes returns the value of x with its bytes in reversed order. This function's execution time does not depend on the inputs.

func ReverseBytes(x uint) uint

ReverseBytes16 function #

ReverseBytes16 returns the value of x with its bytes in reversed order. This function's execution time does not depend on the inputs.

func ReverseBytes16(x uint16) uint16

ReverseBytes32 function #

ReverseBytes32 returns the value of x with its bytes in reversed order. This function's execution time does not depend on the inputs.

func ReverseBytes32(x uint32) uint32

ReverseBytes64 function #

ReverseBytes64 returns the value of x with its bytes in reversed order. This function's execution time does not depend on the inputs.

func ReverseBytes64(x uint64) uint64

RotateLeft function #

RotateLeft returns the value of x rotated left by (k mod [UintSize]) bits. To rotate x right by k bits, call RotateLeft(x, -k). This function's execution time does not depend on the inputs.

func RotateLeft(x uint, k int) uint

RotateLeft16 function #

RotateLeft16 returns the value of x rotated left by (k mod 16) bits. To rotate x right by k bits, call RotateLeft16(x, -k). This function's execution time does not depend on the inputs.

func RotateLeft16(x uint16, k int) uint16

RotateLeft32 function #

RotateLeft32 returns the value of x rotated left by (k mod 32) bits. To rotate x right by k bits, call RotateLeft32(x, -k). This function's execution time does not depend on the inputs.

func RotateLeft32(x uint32, k int) uint32

RotateLeft64 function #

RotateLeft64 returns the value of x rotated left by (k mod 64) bits. To rotate x right by k bits, call RotateLeft64(x, -k). This function's execution time does not depend on the inputs.

func RotateLeft64(x uint64, k int) uint64

RotateLeft8 function #

RotateLeft8 returns the value of x rotated left by (k mod 8) bits. To rotate x right by k bits, call RotateLeft8(x, -k). This function's execution time does not depend on the inputs.

func RotateLeft8(x uint8, k int) uint8

RuntimeError method #

func (e errorString) RuntimeError()

Sub function #

Sub 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.

func Sub(x uint, y uint, borrow uint) (diff uint, borrowOut uint)

Sub32 function #

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.

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

Sub64 function #

Sub64 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.

func Sub64(x uint64, y uint64, borrow uint64) (diff uint64, borrowOut uint64)

TrailingZeros function #

TrailingZeros returns the number of trailing zero bits in x; the result is [UintSize] for x == 0.

func TrailingZeros(x uint) int

TrailingZeros16 function #

TrailingZeros16 returns the number of trailing zero bits in x; the result is 16 for x == 0.

func TrailingZeros16(x uint16) int

TrailingZeros32 function #

TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0.

func TrailingZeros32(x uint32) int

TrailingZeros64 function #

TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0.

func TrailingZeros64(x uint64) int

TrailingZeros8 function #

TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0.

func TrailingZeros8(x uint8) int

Generated with Arrow