IntegerToByteString
scalus.builtin.IntegerToByteString
object IntegerToByteString
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
IntegerToByteString.type
Members list
Value members
Concrete methods
Convert a BigInt into a ByteString.
Convert a BigInt into a ByteString.
The conversion uses fixed-width output and explicit endianness. If lengthArg is 0, the result is a minimal-length encoding.
Value parameters
- endiannessArg
-
truefor big-endian output,falsefor little-endian output. - input
-
Unsigned integer to convert. Negative integers are rejected.
- lengthArg
-
Desired output length in bytes. If zero, the result is minimally sized. If positive, the output must fit into the exact width, otherwise an exception is thrown.
Attributes
- Returns
-
A byte string encoded with the requested width and endianness.
- Throws
-
scalus.uplc.eval.BuiltinException
If the requested length is negative, exceeds the maximum, or the integer cannot be represented in the requested number of bytes.
- See also
- Example
-
// Big-endian, length 2: integerToByteString(true, 2, 4660) == hex"1234" // Little-endian, length 2: integerToByteString(false, 2, 4660) == hex"3412" // Minimal representation: integerToByteString(true, 0, 4660) == hex"1234"
Concrete fields
In this article