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 -
ceilDiv(
int a, int b) → int -
cos(
num x) → double -
ctSelectBool(
bool a, bool b, bool choice) → bool -
ctSelectInt(
int a, int b, bool choice) → int -
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) → List< int> - Encodes an integer into a variable-length byte array according to Bitcoin's variable-length integer encoding scheme.
-
exp(
num x) → double -
fromBytes(
List< int> bytes, {Endian byteOrder = Endian.big, bool sign = false}) → int -
Converts a list of bytes to an integer, following the given byte order.
Uses native int math when safe; otherwise decodes via BigInt and
checks
isValidIntbefore converting back, throwing instead of silently losing precision. -
fromBytes16(
List< int> bytes, {Endian byteOrder = Endian.big, bool sign = false}) → int -
fromBytes32(
List< int> bytes, {Endian byteOrder = Endian.big, bool sign = false}) → int -
fromBytes64(
List< int> bytes, {Endian byteOrder = Endian.big, bool sign = false}) → int -
fromBytes8(
List< int> bytes, {Endian byteOrder = Endian.big, bool sign = false}) → int -
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) → List<int> - Prepends a variable-length integer encoding of the given data length to the provided data.
-
sqrt(
num x) → double -
toBinaryBool(
int value, {int? bitLength}) → List< bool> -
toBytes(
int val, {int? length, Endian byteOrder = Endian.big, bool sign = false}) → List< int> -
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.