bitwise

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package bitwise provides APOC bitwise operations.

This package implements all apoc.bitwise.* functions for bitwise operations on integers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(values ...int64) int64

And performs bitwise AND.

Example:

apoc.bitwise.and(12, 10) => 8

func ClearBit

func ClearBit(value int64, position int) int64

ClearBit sets a specific bit to 0.

Example:

apoc.bitwise.clearBit(9, 0) => 8

func CountBits

func CountBits(value int64) int

CountBits counts the number of set bits (population count).

Example:

apoc.bitwise.countBits(15) => 4

func LeftShift

func LeftShift(value int64, positions int64) int64

LeftShift performs left bit shift.

Example:

apoc.bitwise.leftShift(5, 2) => 20

func Not

func Not(value int64) int64

Not performs bitwise NOT.

Example:

apoc.bitwise.not(12) => -13

func Op

func Op(a int64, operation string, b int64) int64

Op performs a bitwise operation on two integers.

Example:

apoc.bitwise.op(12, '&', 10) => 8

func Or

func Or(values ...int64) int64

Or performs bitwise OR.

Example:

apoc.bitwise.or(12, 10) => 14

func ReverseBits

func ReverseBits(value int64) int64

ReverseBits reverses the bits in a value.

Example:

apoc.bitwise.reverseBits(1) => 9223372036854775808

func RightShift

func RightShift(value int64, positions int64) int64

RightShift performs right bit shift.

Example:

apoc.bitwise.rightShift(20, 2) => 5

func RotateLeft

func RotateLeft(value int64, positions int) int64

RotateLeft rotates bits to the left.

Example:

apoc.bitwise.rotateLeft(1, 2) => 4

func RotateRight

func RotateRight(value int64, positions int) int64

RotateRight rotates bits to the right.

Example:

apoc.bitwise.rotateRight(4, 2) => 1

func SetBit

func SetBit(value int64, position int) int64

SetBit sets a specific bit to 1.

Example:

apoc.bitwise.setBit(8, 0) => 9

func TestBit

func TestBit(value int64, position int) bool

TestBit tests if a specific bit is set.

Example:

apoc.bitwise.testBit(9, 0) => true

func ToggleBit

func ToggleBit(value int64, position int) int64

ToggleBit toggles a specific bit.

Example:

apoc.bitwise.toggleBit(8, 0) => 9

func Xor

func Xor(values ...int64) int64

Xor performs bitwise XOR.

Example:

apoc.bitwise.xor(12, 10) => 6

Types

This section is empty.

Jump to

Keyboard shortcuts

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