Fixed class
Represents a fixed scale decimal no.
The value is stored using the minor units e.g.
Fixed.fromInt(100, scale: 2) == 1.00
- Implemented types
- Annotations
-
- @immutable
Constructors
- Fixed.copyWith(Fixed fixed, {int? scale})
-
Returns a new Fixed value from an existing one
changing the scale to
scale
.factory - Fixed.fromBigInt(BigInt minorUnits, {int scale = 2})
- Creates a fixed scale decimal from minorUnits with the given scale.
- Fixed.fromDecimal(Decimal amount, {int scale = 16})
-
Creates a fixed scale decimal from
amount
with the given scale. - Fixed.fromInt(int minorUnits, {int scale = 2})
-
Creates Fixed scale decimal from
minorUnits
with the given scale. - Fixed.fromNum(num amount, {int scale = 16})
- Creates a Fixed scale value from a double or integer value and stores the value with the given scale.
- Fixed.parse(String amount, {int? scale, bool invertSeparator = false})
-
Parses
amount
as a decimal value.factory
Properties
- abs → Fixed
-
Returns the absolute value of this.
no setter
- decimalPart → BigInt
-
The component of the number after the decimal point.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- integerPart → BigInt
-
The component of the number before the decimal point
no setter
- isNegative → bool
-
returns true of the value of this is negative.
no setter
- isPositive → bool
-
returns true if the value of this is positive.
no setter
- isZero → bool
-
returns true if the value of this is zero.
no setter
- minorUnits ↔ BigInt
-
The value of this Fixed instance stored as minorUnits in a BigInt.
If the scale is 2 then 1 is stored as 100
If the scale is 3 then 1 is stored as 1000.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → int
-
Returns this as minor units.
final
- scaleFactor → BigInt
-
Returns 10 ^ scale
no setter
- sign → int
-
Returns the sign of this amount.
no setter
Methods
-
allocationAccordingTo(
List< int> ratios) → List<Fixed> -
Spread the value across 'n' Fixed values according
to the supplie
ratios
. -
compareTo(
Fixed other) → int -
Two Fixed instances are the same if they have
the same minorUnits and the same scale.
override
-
divide(
num divisor) → Fixed -
Returns this /
divisor
. -
format(
String pattern, {bool invertSeparator = false}) → String -
Formats a Fixed value into a String according to the
passed
pattern
. -
formatIntl(
[String? locale]) → String -
Formats the value using the
locale
's decimal pattern. -
multiply(
num multiplier) → Fixed -
Returns this *
multiplier
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pow(
int exponent) → Fixed -
Returns this ^
exponent
-
remainder(
Fixed divisor) → Fixed -
Returns the remainder of dividing this /
divisor
. -
toDecimal(
) → Decimal -
Returns the value as a
Decimal
-
toInt(
) → int - Truncates this and returns the integer part.
-
toString(
) → String -
Returns the Fixed value using scale to control the
displayed number of decimal places.
override
Operators
-
operator %(
Fixed denominator) → Fixed -
Returns this %
denominator
. -
operator *(
Fixed multiplier) → Fixed -
Returns this *
multiplier
. -
operator +(
Fixed addition) → Fixed -
Returns this +
addition
-
operator -(
Fixed subtration) → Fixed -
Returns this -
subtration
-
operator /(
Fixed denominator) → Fixed -
Returns this /
denominator
-
operator <(
Fixed other) → bool - less than operator
-
operator <=(
Fixed other) → bool - less than or equal operator
-
operator ==(
covariant Fixed other) → bool -
Two Fixed values are considered equal if they have
the same value irrespective of scale.
override
-
operator >(
Fixed other) → bool - greater than operator
-
operator >=(
Fixed other) → bool - greater than or equal operator
-
operator unary-(
) → Fixed - Returns -this.
-
operator ~/(
Fixed denominator) → Fixed -
Returns the this ~/
denominator