math.bits #

fn add_32 #

fn add_32(x u32, y u32, carry u32) (u32, u32)

--- Add with carry --- 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. add_32 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.

fn add_64 #

fn add_64(x u64, y u64, carry u64) (u64, u64)

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

fn div_32 #

fn div_32(hi u32, lo u32, y u32) (u32, u32)

--- Full-width divide --- div_32 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_32 panics for y == 0 (division by zero) or y <= hi (quotient overflow).

fn div_64 #

fn div_64(hi u64, lo u64, y1 u64) (u64, u64)

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

fn leading_zeros_16 #

fn leading_zeros_16(x u16) int

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

fn leading_zeros_32 #

fn leading_zeros_32(x u32) int

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

fn leading_zeros_64 #

fn leading_zeros_64(x u64) int

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

fn leading_zeros_8 #

fn leading_zeros_8(x byte) int

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

fn len_16 #

fn len_16(x u16) int

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

fn len_32 #

fn len_32(x u32) int

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

fn len_64 #

fn len_64(x u64) int

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

fn len_8 #

fn len_8(x byte) int

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

fn mul_32 #

fn mul_32(x u32, y u32) (u32, u32)

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

fn mul_64 #

fn mul_64(x u64, y u64) (u64, u64)

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

fn ones_count_16 #

fn ones_count_16(x u16) int

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

fn ones_count_32 #

fn ones_count_32(x u32) int

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

fn ones_count_64 #

fn ones_count_64(x u64) int

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

fn ones_count_8 #

fn ones_count_8(x byte) int

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

fn rem_32 #

fn rem_32(hi u32, lo u32, y u32) u32

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

fn rem_64 #

fn rem_64(hi u64, lo u64, y u64) u64

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

fn reverse_16 #

fn reverse_16(x u16) u16

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

fn reverse_32 #

fn reverse_32(x u32) u32

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

fn reverse_64 #

fn reverse_64(x u64) u64

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

fn reverse_8 #

fn reverse_8(x byte) byte

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

fn reverse_bytes_16 #

fn reverse_bytes_16(x u16) u16

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

fn reverse_bytes_32 #

fn reverse_bytes_32(x u32) u32

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

fn reverse_bytes_64 #

fn reverse_bytes_64(x u64) u64

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

fn rotate_left_16 #

fn rotate_left_16(x u16, k int) u16

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

fn rotate_left_32 #

fn rotate_left_32(x u32, k int) u32

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

fn rotate_left_64 #

fn rotate_left_64(x u64, k int) u64

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

fn rotate_left_8 #

fn rotate_left_8(x byte, k int) byte

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

fn sub_32 #

fn sub_32(x u32, y u32, borrow u32) (u32, u32)

--- Subtract with borrow --- 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. sub_32 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.

fn sub_64 #

fn sub_64(x u64, y u64, borrow u64) (u64, u64)

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

fn trailing_zeros_16 #

fn trailing_zeros_16(x u16) int

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

fn trailing_zeros_32 #

fn trailing_zeros_32(x u32) int

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

fn trailing_zeros_64 #

fn trailing_zeros_64(x u64) int

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

fn trailing_zeros_8 #

fn trailing_zeros_8(x byte) int

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