HbNum class

Utility class for numerical operations with null safety

Provides methods for basic arithmetic operations, comparisons, and finding min/max values with support for both num and String types. Uses Decimal for precise decimal arithmetic to avoid floating point errors.

Constructors

HbNum()

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

add(num? a, num? b) → Decimal
加 a+b Adds two nullable numbers with precise decimal arithmetic
addStr(String? a, String? b) → Decimal
加 a+b Adds two nullable strings representing numbers
addStrList(List<String?> aList) → Decimal
Sums a list of nullable strings representing numbers
divide(num? a, num? b) → Decimal
除 a/b Divides first nullable number by second Returns zero if denominator is zero
divideStr(String? a, String? b) → Decimal
除 a/b Divides first nullable string number by second Returns zero if denominator is zero
greaterOrEqual(num? a, num? b) bool
大于等于 a>=b Checks if first number is greater than or equal to second
greaterOrEqualStr(String? a, String? b) bool
大于等于 a>=b Checks if first string number is greater than or equal to second
greaterThan(num? a, num? b) bool
大于 a>b Checks if first number is greater than second
greaterThanStr(String? a, String? b) bool
大于 a>b Checks if first string number is greater than second
lessThan(num? a, num? b) bool
小于 a<b Checks if first number is less than second
lessThanStr(String? a, String? b) bool
小于 a<b Checks if first string number is less than second
max<T>(T? a, T? b) → T?
最大值 Returns the maximum of two values Works with String and num types
min<T>(T? a, T? b) → T?
最小值 Returns the minimum of two values Works with String and num types
multiply(num? a, num? b) → Decimal
乘 a*b Multiplies two nullable numbers
multiplyStr(String? a, String? b) → Decimal
乘 a*b Multiplies two nullable string numbers
remainder(num? a, num? b) → Decimal
余数 a%b Calculates remainder when dividing first number by second
remainderStr(String? a, String? b) → Decimal
余数 a%b Calculates remainder for string numbers
subtract(num? a, num? b) → Decimal
减 a-b Subtracts second nullable number from first
subtractStr(String? a, String? b) → Decimal
减 a-b Subtracts second nullable string number from first
subtractStrMinZero(String? a, String? b) String
减 a-b,最小值为0 Subtracts with minimum result of zero Returns "0" if result would be negative
thanOrEqual(num? a, num? b) bool
小于等于 a<=b Checks if first number is less than or equal to second
thanOrEqualStr(String? a, String? b) bool
小于等于 a<=b Checks if first string number is less than or equal to second