IntUtils class
Utility class for integer-related operations and conversions.
Constructors
- IntUtils()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
bitlengthInBytes(
int value, {bool sign = false}) → int -
Minimum number of bytes needed to hold
value(add a sign bit whensignis true). -
ceilDiv(
int a, int b) → int - Integer division rounding up instead of toward zero.
-
cos(
num x) → double -
ctSelectBool(
bool a, bool b, bool choice) → bool -
Branchless select: returns
bifchoiceelsea. -
ctSelectInt(
int a, int b, bool choice) → int -
Branchless select: returns
bifchoiceelsea. -
decodeVarint(
List< int> byteint) → (int, int) - Decodes a variable-length byte array into an integer value according to Bitcoin's variable-length integer encoding scheme.
-
encodeVarint(
int value) → BuBytes -
exp(
num x) → double -
fromBytes(
List< int> bytes, {int offset = 0, int? length, Endian byteOrder = Endian.big, bool sign = false}) → int - Converts a list of bytes to an integer, following the given byte order.
-
fromBytes16(
List< int> bytes, {int offset = 0, Endian byteOrder = Endian.big, bool sign = false}) → int - Reads 2 bytes as an integer.
-
fromBytes32(
List< int> bytes, {int offset = 0, Endian byteOrder = Endian.big, bool sign = false}) → int - Reads 4 bytes as an integer.
-
fromBytes64(
List< int> bytes, {int offset = 0, Endian byteOrder = Endian.big, bool sign = false}) → int - Reads 8 bytes as an integer.
-
fromBytes8(
List< int> bytes, {int offset = 0, Endian byteOrder = Endian.big, bool sign = false}) → int - Reads a single byte as an integer.
-
log(
num x) → double -
max(
int a, int b) → int -
min(
int a, int b) → int -
parse(
dynamic number, {bool allowHex = true}) → int -
Parses a dynamic value
numberinto an integer. -
pow(
num x, num exponent) → num -
prependVarint(
List< int> data) → BuBytes -
sqrt(
num x) → double -
toBinaryBool(
int value, {int? bitLength}) → List< bool> -
Expands
valueinto individual bits, LSB first. -
toBytes(
int val, {int? length, Endian byteOrder = Endian.big, bool sign = false}) → BuBytes -
Converts an integer to a byte list with the given length and byte
order. Pass
sign: trueto allow/encode negative values as two's complement. Length auto-sizing (whenlengthis omitted) uses the samesignconvention, so the result always round-trips correctly. -
tryParse(
dynamic number, {bool allowHex = true}) → int? -
Tries to parse a dynamic value
numberinto an integer, returning null if parsing fails.