bitsUtil

package
v0.0.0-...-d1ade8f Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(x, y uint) uint

And returns x&y.

func AndNot

func AndNot(x, y uint) uint

AndNot returns x&^y.

func DivideBy2n

func DivideBy2n(x uint, n int) uint

DivideBy2n returns x/2^n.

func IsDivisibleBy8

func IsDivisibleBy8(x uint) bool

IsDivisibleBy8 returns true if x is divisible by 8.

func IsEven

func IsEven(x uint) bool

IsEven returns true if x is even.

func IsPowerOf2

func IsPowerOf2(x uint) bool

IsPowerOf2 returns true if x is a power of 2.

func IsSameSign

func IsSameSign(x, y int) bool

IsSameSign returns true if x and y have same signs.

func IsSetNth

func IsSetNth(x uint, n int) bool

IsSetNth returns true if the nth bit of x is set.

func LeftShift

func LeftShift(x uint, n int) uint

LeftShift returns x<<n.

func MultiplyBy2n

func MultiplyBy2n(x uint, n int) uint

MultiplyBy2n returns x*2^n.

func Not

func Not(x uint) uint

Not returns ^x.

func Or

func Or(x, y uint) uint

Or returns x|y.

func RightShift

func RightShift(x uint, n int) uint

RightShift returns x>>n.

func SetNth

func SetNth(x uint, n int) uint

SetNth returns x with the nth bit set to 1, and n start from 0 and rightmost.

func ToggleExceptNth

func ToggleExceptNth(x uint, n int) uint

ToggleExceptNth returns x with all bits except the nth bit toggled, and n start from 0 and rightmost.

func ToggleLeftN

func ToggleLeftN(x uint, n int) uint

ToggleLeftN returns x with the leftmost n bits toggled.

func ToggleNth

func ToggleNth(x uint, n int) uint

ToggleNth returns x with the nth bit toggled, and n start from 0 and rightmost.

func ToggleRightN

func ToggleRightN(x uint, n int) uint

ToggleRightN returns x with the rightmost n bits toggled.

func UnsetNth

func UnsetNth(x uint, n int) uint

UnsetNth returns x with the nth bit set to 0, and n start from 0 and rightmost.

func Xor

func Xor(x, y uint) uint

Xor returns x^y.

Types

This section is empty.

Jump to

Keyboard shortcuts

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