After over a year of forgetting that I promised a V2 for the SimpleBit module that I’ve made back in early 2022.

## SIMPLEBIT V2

### SimpleBit.b32

`includes all bit32 functions`

## .scramble()

```
SimpleBit.b32.scramble(text: string, aSeed: number, bSeed: number): string
```

Using a sequence of bitwise operations using the aSeed and bSeed, the output is a string, being scrambled. Changing the key will change the results.

## .float32()

```
SimpleBit.b32.float32(n: number): number
Returns the first 32 bits of the float of the number.
```

## .bnand()

```
SimpleBit.b32.bnand(n: number): number
```

The bitwise nand function, not present in roblox’s default bit32 library.

## .packBooleans()

```
SimpleBit.b32.packBooleans(...:Boolean): number
```

Takes in a tuple of booleans, upto 32 booleans, and stores them in a number.

## .unpackBooleans()

```
SimpleBit.b32.unpackBooleans(n: number): ...Boolean
```

Returns a tuple of all 32 boolean values representing the binary values, you can always use select() to chose the tuple you want.

## .packColors()

```
SimpleBit.b32.packColors(x: {Color3}): {number}
```

Packs color3 values into a number. Saves space by saving R, G and B values as a single number instead of 3.

## .unpackColors()

```
SimpleBit.b32.unpackColors(x: {number}): {Color3}
```

Unpacks the values of numbers into color3 values.

## .random_flip()

```
SimpleBit.b32.random_flip(number: number, seed: number)
```

Performs the xor operation with the number and a random number between 0 and * 2^32-1*, with the seed being the randomseed used for the random generation.

## .random_significant()

```
SimpleBit.b32.random_significant(randomseed: number?): number
```

Returns a random number, but each bit *(index: * has a chance of

`i`

)*for the bit to be toggled on. I.E there is a 100% chance of getting BIT0, 50% chance of getting BIT1, ect.*

`1 / 2 ^ (i - 1)`

* SimpleBit.b32.sign_bnot()* is the same as bit32.bnot, but it only performs the NOT operation to the highest bit.

### SimpleBit.b64

Has commands: * bor(), bnot(), band(), bnand(), bxor()*, similar to its bit32 counterparts, but it can do these operations for numbers upto

*instead of the bit32 limit of*

`18,446,744,073,709,552,000`

*.*

`4,294,967,295`

* SimpleBit.b64.splitB2()* takes in an integer, anywhere between

*and*

`0`

*, and splits it into two integers, smaller than*

`18,446,744,073,709,552,000`

*, so that they can be proccessed by bit32 and other functions.*

`2^32`

## METATABLES

How to use the new SimpleBit metatables?

First of all, import the module to your script:

Use the * simpleBit.new()* function to turn a number into a bitobject:

You can use the following operations for bitwise operations:

* #bitobject* gets the index of the highest bit in the number

*(i.e how many bits the number needs)*

* bitobject()* gets the bit32 number of the object.

* bitobject ^ bitobject* performs the XOR operation

* bitobject + bitobject* performs the AND operation

* bitobject - bitobject* performs the AND(a, NOT(b)), operation. Similar to XOR but any bits present in b and not in a aren’t added.

* bitobject > bitobject* shifts the first b.o by the second b.o to the right.

* bitobject < bitobject* shifts the first b.o by the second b.o to the left.

* bitobject >= bitobject* rotates the first b.o by the second b.o to the left.

* bitobject <= bitobject* rotates the first b.o by the second b.o to the right.

* -bitobject* returns the INVERSE of bitobject.

* bitobject * bitobject* performs the OR OPERATION

**NOTE:**

Apart from the operator functions *(<, >, <=, >=)*, all these functions return the result for the operation and do not change the actual bitobject, whilst the operator functions actually modify the bitobject.