Liking cljdoc? Tell your friends :D

frereth.cp.shared.bit-twiddling

Shared functions for fiddling with bits

Shared functions for fiddling with bits
raw docstring

->stringclj

(->string x)
source

byte-copy!clj

(byte-copy! dst src)
(byte-copy! dst offset n src)
(byte-copy! dst offset n src src-offset)

Copies the bytes from src to dst

Copies the bytes from src to dst
sourceraw docstring

bytes=clj

(bytes= x y)
source

extract-rightmost-byteclj

(extract-rightmost-byte n)

Since bytes are signed in java

Since bytes are signed in java
sourceraw docstring

possibly-2s-complement-8clj

(possibly-2s-complement-8 n)

If an unsigned byte is greater than 127, it needs to be negated to fit into a signed byte.

Thanks, java, for having a crippled numeric stack.

If an unsigned byte is greater than 127, it needs to be negated to fit into a signed byte.

Thanks, java, for having a crippled numeric stack.
sourceraw docstring

possibly-2s-uncomplement-16clj

(possibly-2s-uncomplement-16 n)

Note that this is specifically for a pair of bytes

Note that this is specifically for a pair of bytes
sourceraw docstring

possibly-2s-uncomplement-32clj

(possibly-2s-uncomplement-32 n)

Note that this is specifically for a quad-byte

Note that this is specifically for a quad-byte
sourceraw docstring

possibly-2s-uncomplement-64clj

(possibly-2s-uncomplement-64 n)

Note that this is specifically for an 8 byte sequence

Note that this is specifically for an 8 byte sequence
sourceraw docstring

possibly-2s-uncomplement-8clj

(possibly-2s-uncomplement-8 n)

Note that this is specifically for a single byte

Note that this is specifically for a single byte
sourceraw docstring

possibly-2s-uncomplement-nclj

(possibly-2s-uncomplement-n n maximum)

Convert [signed] complemented n into unsigned that fits maximum

Convert [signed] complemented n into unsigned that fits maximum
sourceraw docstring

secure-modclj

(secure-mod numerator denominator)

DJB sort-of uses this approach in randommod.

Do not use.

It's significantly slower than ordinary mod

I'm pretty sure its only purpoe in life is that C doesn't support really big numbers.

On lots of platforms, a long long is only 64 bits.

Since we're looking at 256 bits right off the bat, java wins here.

DJB sort-of uses this approach in randommod.

Do not use.

It's significantly slower than ordinary mod

I'm pretty sure its only purpoe in life is
that C doesn't support really big numbers.

On lots of platforms, a long long is only 64 bits.

Since we're looking at 256 bits right off the
bat, java wins here.
sourceraw docstring

sub-byte-arrayclj

(sub-byte-array src beg)
(sub-byte-array src beg end)

Return an array that copies a portion of the source

Return an array that copies a portion of the source
sourceraw docstring

uint-pack!clj

(uint-pack! dst index src size)
source

uint16-packclj

(uint16-pack x)
source

uint16-pack!clj

(uint16-pack! dst index src)

Sets 2 bytes in dst (starting at offset n) to x

Sets 2 bytes in dst (starting at offset n) to x
sourceraw docstring

uint16-unpackclj

(uint16-unpack src)
(uint16-unpack src offset)

Unpack an array of 2 bytes into a 16-bit short

Unpack an array of 2 bytes into a 16-bit short
sourceraw docstring

uint32-pack!clj

(uint32-pack! dst index src)

Sets 4 bytes in dst (starting at offset n) to x

Sets 4 bytes in dst (starting at offset n) to x
sourceraw docstring

uint32-unpackclj

(uint32-unpack src)

Unpack an array of 32 bytes into a 32-bit long

Unpack an array of 32 bytes into a 32-bit long
sourceraw docstring

uint64-packclj

(uint64-pack x)
source

uint64-pack!clj

(uint64-pack! dst index src)

Sets 8 bytes in dst (starting at offset n) to x

Note that this looks/smells very similar to TweetNaclFast's Box.generateNonce.

But I don't see an obvious way to reverse that, and it's buried inside a class.

So stick with this translation.

Sets 8 bytes in dst (starting at offset n) to x

Note that this looks/smells very similar to TweetNaclFast's
Box.generateNonce.

But I don't see an obvious way to reverse that, and it's
buried inside a class.

So stick with this translation.
sourceraw docstring

uint64-unpackclj

(uint64-unpack src)

Unpack an array of 8 bytes into a 64-bit long

Unpack an array of 8 bytes into a 64-bit long
sourceraw docstring

zero-out!clj

(zero-out! dst start end)

Shove zeros into the byte-array at dst, from offset start to offset end

Shove zeros into the byte-array at dst, from offset start to offset end
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close