Module: stdgo.math.bits
Overview
Index
-
function add(_x:UInt, _y:UInt, _carry:UInt):stdgo.Tuple<UInt, UInt>
-
function add32(_x:UInt, _y:UInt, _carry:UInt):stdgo.Tuple<UInt, UInt>
-
function div(_hi:UInt, _lo:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
-
function div32(_hi:UInt, _lo:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
-
function mul64(_x:haxe.UInt64, _y:haxe.UInt64):stdgo.Tuple<haxe.UInt64, haxe.UInt64>
-
function rem64(_hi:haxe.UInt64, _lo:haxe.UInt64, _y:haxe.UInt64):haxe.UInt64
-
function sub(_x:UInt, _y:UInt, _borrow:UInt):stdgo.Tuple<UInt, UInt>
-
function sub32(_x:UInt, _y:UInt, _borrow:UInt):stdgo.Tuple<UInt, UInt>
Constants
import stdgo.math.bits.Bits
final deBruijn64:haxe.UInt64 = stdgo._internal.math.bits.Bits_deBruijn64.deBruijn64
final uintSize:haxe.UInt64 = stdgo._internal.math.bits.Bits_uintSize.uintSize
Classes
import stdgo.math.bits.*
class Bits
Package bits implements bit counting and manipulation
functions for the predeclared unsigned integer types.
Functions in this package may be implemented directly by the compiler, for better performance. For those functions the code in this package will not be used. Which functions are implemented by the compiler depends on the architecture and the Go release.
Bits function add
function add(_x:UInt, _y:UInt, _carry:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function add32
function add32(_x:UInt, _y:UInt, _carry:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function add64
function add64(_x:haxe.UInt64, _y:haxe.UInt64, _carry:haxe.UInt64):stdgo.Tuple<haxe.UInt64, haxe.UInt64>
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.
Bits function div
function div(_hi:UInt, _lo:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
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).
Bits function div32
function div32(_hi:UInt, _lo:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
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).
Bits function div64
function div64(_hi:haxe.UInt64, _lo:haxe.UInt64, _y:haxe.UInt64):stdgo.Tuple<haxe.UInt64, haxe.UInt64>
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).
Bits function leadingZeros
function leadingZeros(_x:UInt):Int
LeadingZeros returns the number of leading zero bits in x; the result is UintSize for x == 0.
Bits function leadingZeros16
function leadingZeros16(_x:UInt):Int
LeadingZeros16 returns the number of leading zero bits in x; the result is 16 for x == 0.
Bits function leadingZeros32
function leadingZeros32(_x:UInt):Int
LeadingZeros32 returns the number of leading zero bits in x; the result is 32 for x == 0.
Bits function leadingZeros64
function leadingZeros64(_x:haxe.UInt64):Int
LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0.
Bits function leadingZeros8
function leadingZeros8(_x:UInt):Int
LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0.
Bits function len
function len(_x:UInt):Int
Len returns the minimum number of bits required to represent x; the result is 0 for x == 0.
Bits function len16
function len16(_x:UInt):Int
Len16 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
Bits function len32
function len32(_x:UInt):Int
Len32 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
Bits function len64
function len64(_x:haxe.UInt64):Int
Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
Bits function len8
function len8(_x:UInt):Int
Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
Bits function mul
function mul(_x:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function mul32
function mul32(_x:UInt, _y:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function mul64
function mul64(_x:haxe.UInt64, _y:haxe.UInt64):stdgo.Tuple<haxe.UInt64, haxe.UInt64>
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.
Bits function onesCount
function onesCount(_x:UInt):Int
OnesCount returns the number of one bits ("population count") in x.
Bits function onesCount16
function onesCount16(_x:UInt):Int
OnesCount16 returns the number of one bits ("population count") in x.
Bits function onesCount32
function onesCount32(_x:UInt):Int
OnesCount32 returns the number of one bits ("population count") in x.
Bits function onesCount64
function onesCount64(_x:haxe.UInt64):Int
OnesCount64 returns the number of one bits ("population count") in x.
Bits function onesCount8
function onesCount8(_x:UInt):Int
OnesCount8 returns the number of one bits ("population count") in x.
Bits function rem
function rem(_hi:UInt, _lo:UInt, _y:UInt):UInt
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.
Bits function rem32
function rem32(_hi:UInt, _lo:UInt, _y:UInt):UInt
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.
Bits function rem64
function rem64(_hi:haxe.UInt64, _lo:haxe.UInt64, _y:haxe.UInt64):haxe.UInt64
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.
Bits function reverse
function reverse(_x:UInt):UInt
Reverse returns the value of x with its bits in reversed order.
Bits function reverse16
function reverse16(_x:UInt):UInt
Reverse16 returns the value of x with its bits in reversed order.
Bits function reverse32
function reverse32(_x:UInt):UInt
Reverse32 returns the value of x with its bits in reversed order.
Bits function reverse64
function reverse64(_x:haxe.UInt64):haxe.UInt64
Reverse64 returns the value of x with its bits in reversed order.
Bits function reverse8
function reverse8(_x:UInt):UInt
Reverse8 returns the value of x with its bits in reversed order.
Bits function reverseBytes
function reverseBytes(_x:UInt):UInt
ReverseBytes returns the value of x with its bytes in reversed order.
This function's execution time does not depend on the inputs.
Bits function reverseBytes16
function reverseBytes16(_x:UInt):UInt
ReverseBytes16 returns the value of x with its bytes in reversed order.
This function's execution time does not depend on the inputs.
Bits function reverseBytes32
function reverseBytes32(_x:UInt):UInt
ReverseBytes32 returns the value of x with its bytes in reversed order.
This function's execution time does not depend on the inputs.
Bits function reverseBytes64
function reverseBytes64(_x:haxe.UInt64):haxe.UInt64
ReverseBytes64 returns the value of x with its bytes in reversed order.
This function's execution time does not depend on the inputs.
Bits function rotateLeft
function rotateLeft(_x:UInt, _k:Int):UInt
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.
Bits function rotateLeft16
function rotateLeft16(_x:UInt, _k:Int):UInt
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.
Bits function rotateLeft32
function rotateLeft32(_x:UInt, _k:Int):UInt
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.
Bits function rotateLeft64
function rotateLeft64(_x:haxe.UInt64, _k:Int):haxe.UInt64
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.
Bits function rotateLeft8
function rotateLeft8(_x:UInt, _k:Int):UInt
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.
Bits function sub
function sub(_x:UInt, _y:UInt, _borrow:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function sub32
function sub32(_x:UInt, _y:UInt, _borrow:UInt):stdgo.Tuple<UInt, UInt>
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.
Bits function sub64
function sub64(_x:haxe.UInt64, _y:haxe.UInt64, _borrow:haxe.UInt64):stdgo.Tuple<haxe.UInt64, haxe.UInt64>
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.
Bits function trailingZeros
function trailingZeros(_x:UInt):Int
TrailingZeros returns the number of trailing zero bits in x; the result is UintSize for x == 0.
Bits function trailingZeros16
function trailingZeros16(_x:UInt):Int
TrailingZeros16 returns the number of trailing zero bits in x; the result is 16 for x == 0.
Bits function trailingZeros32
function trailingZeros32(_x:UInt):Int
TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0.
Bits function trailingZeros64
function trailingZeros64(_x:haxe.UInt64):Int
TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0.
Bits function trailingZeros8
function trailingZeros8(_x:UInt):Int
TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0.
Typedefs
import stdgo.math.bits.*
typedef T_errorString
typedef T_errorString = stdgo._internal.math.bits.T_errorString;