ByteStringToInteger

scalus.builtin.ByteStringToInteger

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def byteStringToInteger(statedEndiannessArg: Boolean, input: ByteString): BigInt

Convert a ByteString into a non-negative BigInt.

Convert a ByteString into a non-negative BigInt.

Leading zero bytes are ignored. The interpretation is unsigned.

Value parameters

input

The byte string to convert. Empty or all-zero strings yield 0.

statedEndiannessArg

true for big-endian interpretation, false for little-endian interpretation.

Attributes

Returns

The unsigned integer represented by the input bytes.

See also
Note

This function mirrors integerToByteString.

Example
 // Big-endian
 byteStringToInteger(true, hex"1234") == 4660
 // Little-endian
 byteStringToInteger(false, hex"3412") == 4660
 // Leading zeros ignored
 byteStringToInteger(true,  hex"001234") == 4660