FdcDecimal class

Fixed-scale decimal value used by decimal field runtime values.

The value is stored as an integer scaled by scale, so decimal input does not lose precision through binary floating point representation. Use toString or toStringAsFixed for exact text output, and toNum only when interoperating with UI/progress/filter code that still expects numeric values.

Implemented types

Constructors

FdcDecimal.fromNum(num value, {int? scale})
Creates a decimal from a finite Dart number.
factory
FdcDecimal.fromScaled(BigInt scaledValue, {required int scale})
Creates a decimal from an already scaled integer value.
factory
FdcDecimal.parse(String text, {int? scale, String decimalSeparator = '.', String? thousandSeparator, bool negative = true, bool allowCommaDecimalFallback = true})
Parses decimal text.
factory
FdcDecimal.parseNormalized(String normalizedText, {required int scale})
Creates a decimal from a normalized numeric text using . as decimal separator. The text may be rounded to scale before storage.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
isNegative bool
True when the represented decimal value is less than zero.
no setter
isZero bool
True when the represented decimal value is exactly zero.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale int
Number of decimal fraction digits represented by scaledValue.
final
scaledValue BigInt
Integer value scaled by 10^scale.
final

Methods

abs() FdcDecimal
Returns the absolute value.
ceil() int
Returns the smallest integer value not less than this value.
clamp(Object lowerLimit, Object upperLimit) FdcDecimal
Clamps this value to the inclusive range from lowerLimit to upperLimit.
compareTo(FdcDecimal other) int
Compares this object to another object.
override
floor() int
Returns the greatest integer value not greater than this value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
round() int
Rounds to the nearest integer value.
toDouble() double
Converts this decimal to a double-precision floating-point value.
toInt() int
Truncates the fractional part and returns the integer component.
toNum() num
Converts this decimal to an int when exact, otherwise to a double.
toString() String
A string representation of this object.
override
toStringAsFixed([int? fractionDigits]) String
Formats with exactly fractionDigits digits after the decimal point.
truncate() int
Removes the fractional part toward zero.

Operators

operator %(Object other) FdcDecimal
Returns the remainder after dividing this decimal by other.
operator *(Object other) FdcDecimal
Multiplies this decimal by other. The exact result scale is the sum of the operand scales. When that would exceed the supported decimal scale range, the result is rounded back to scale 38 instead of throwing for two otherwise valid decimal operands.
operator +(Object other) FdcDecimal
Adds other to this decimal and keeps the larger operand scale.
operator -(Object other) FdcDecimal
Subtracts other from this decimal and keeps the larger operand scale.
operator /(Object other) → dynamic
Divides this decimal by other. Division by zero returns a non-finite numeric value so calculated field validation can report the error instead of failing during calculation.
operator <(Object other) bool
Returns whether this decimal is less than other.
operator <=(Object other) bool
Returns whether this decimal is less than or equal to other.
operator ==(Object other) bool
The equality operator.
override
operator >(Object other) bool
Returns whether this decimal is greater than other.
operator >=(Object other) bool
Returns whether this decimal is greater than or equal to other.
operator unary-() FdcDecimal
Returns this decimal with the sign inverted.
operator ~/(Object other) int
Integer division using decimal-safe operands.

Static Properties

one FdcDecimal
Returns the current one.
no setter
zero FdcDecimal
Returns the current zero.
no setter

Static Methods

tryFromNum(num value, {int? scale}) FdcDecimal?
Converts a finite num through its decimal text representation.
tryParse(String text, {int? scale, String decimalSeparator = '.', String? thousandSeparator, bool negative = true, bool allowCommaDecimalFallback = true}) FdcDecimal?
Parses user text using optional localized separators and stores it at the requested scale.
tryParseNormalized(String normalizedText, {required int scale}) FdcDecimal?
Parses normalized decimal text, returning null for invalid input.