(decode-ascii-str b-seq)
Returns the contents of b-seq
encoded as ascii string up to first occurence of 0 or the end of sequence.
Returns the contents of `b-seq` encoded as ascii string up to first occurence of 0 or the end of sequence.
(decode-bits bin-seq)
Returns the decimal value of bin-seq
, where bin-seq
is a list of 8 bits (0 or 1).
Example usage:
=> (decode-bits [0 0 1 0 1 1 1 0])
46
Returns the decimal value of `bin-seq`, where `bin-seq` is a list of 8 bits (0 or 1). Example usage: ``` => (decode-bits [0 0 1 0 1 1 1 0]) 46 ```
(decode-float32 [b0 b1 b2 b3])
Returns the decimal value of a seq of four bytes interpred as single precision floating number.
Returns the decimal value of a *seq of four bytes* interpred as single precision floating number.
(decode-slong [b0 b1 b2 b3])
Returns the base 10 value of a seq of four bytes interpreted as a signed long (32 bit integer).
Example usage:
=> (decode-slong [-2 -30 118 108])
-18712980
Returns the base 10 value of a *seq of four bytes* interpreted as a signed long (32 bit integer). Example usage: ``` => (decode-slong [-2 -30 118 108]) -18712980 ```
(decode-slongrational [b0 b1 b2 b3 b4 b5 b6 b7])
Returns the rational value of a seq of eight bytes interpreted as two signed longs (32 bit integers). First four bytes form the numerator and the last four bytes form the denominator.
Example usage:
=> (decode-slongrational [34 41 -113 80 -33 -21 9 33])
-573149008/538244831
Returns the rational value of a *seq of eight bytes* interpreted as two signed longs (32 bit integers). First four bytes form the numerator and the last four bytes form the denominator. Example usage: ``` => (decode-slongrational [34 41 -113 80 -33 -21 9 33]) -573149008/538244831 ```
(decode-sshort [b0 b1])
Returns the base 10 value of a seq of two bytes interpreted as a signed short (16 bit integer).
Example usage:
=> (decode-sshort [12 -30])
3298
Returns the base 10 value of a *seq of two bytes* interpreted as a signed short (16 bit integer). Example usage: ``` => (decode-sshort [12 -30]) 3298 ```
(decode-ubyte b)
Returns the base 10 value of b
interpreted as an unsigned byte (8 bit integer), where b
is a byte or and integer from -128 to 127.
Returns the base 10 value of `b` interpreted as an unsigned byte (8 bit integer), where `b` is a **byte** or and integer from -128 to 127.
(decode-ulong [b0 b1 b2 b3])
Returns the base 10 value of a seq of four bytes interpreted as an unsigned long (32 bit integer).
Example usage:
=> (decode-ulong [-2 -30 118 108])
4276254316
Returns the base 10 value of a *seq of four bytes* interpreted as an unsigned long (32 bit integer). Example usage: ``` => (decode-ulong [-2 -30 118 108]) 4276254316 ```
(decode-ulongrational [b0 b1 b2 b3 b4 b5 b6 b7])
Returns the rational value of a seq of eight bytes interpreted as two unsigned longs (32 bit integers). First four bytes form the numerator and the last four bytes form the denominator.
Example usage:
=> (decode-ulongrational [34 41 -113 80 -33 -21 9 33])
573149008/3756722465
Returns the rational value of a *seq of eight bytes* interpreted as two unsigned longs (32 bit integers). First four bytes form the numerator and the last four bytes form the denominator. Example usage: ``` => (decode-ulongrational [34 41 -113 80 -33 -21 9 33]) 573149008/3756722465 ```
(decode-ushort [b0 b1])
Returns the base 10 value of a seq of two bytes interpreted as an unsigned short (16 bit integer).
Example usage:
=> (decode-ushort [12 -30])
3298
Returns the base 10 value of a *seq of two bytes* interpreted as an unsigned short (16 bit integer). Example usage: ``` => (decode-ushort [12 -30]) 3298 ```
(encode-bits n)
Returns a list of 8 bits (0 or 1) that represents the number n
in base 2.
n
is a unsigned byte or an integer from 0 to 255 inclusive.
Example usage:
=> (encode-bits 22)
(0 0 0 1 0 1 1 0)
Returns a list of 8 bits (0 or 1) that represents the number `n` in base 2. `n` is a unsigned byte or an integer from 0 to 255 inclusive. Example usage: ``` => (encode-bits 22) (0 0 0 1 0 1 1 0) ```
(slurp-bytes uri)
Attempts to open uri as input stream and copy its content to a byte array.
Attempts to open uri as input stream and copy its content to a byte array.
(spit-bytes filename content & opt)
Saves content
to filename
. Passes opt
to output stream.
Saves `content` to `filename`. Passes `opt` to output stream.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close