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
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 = 2})
-
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 = 2})
- Creates a Fixed scale value from a double or integer value and stores the value with a the given scale.
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
-
Returns this as minor units.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → int
-
The scale to which we store the amount.
final
- scaleFactor → BigInt
-
Returns 10 ^ scale
no setter
- sign → int
-
Returns the sign of this amount.
no setter
- value ↔ Decimal
-
The value of this stored as a
Decimal
.latefinal
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 value 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 divisor) → Fixed -
Returns this %
divisor
. -
operator *(
Fixed multiplier) → Fixed -
Returns this *
multiplier
. -
operator +(
Fixed addition) → Fixed -
Returns this +
addition
-
operator -(
Fixed subtration) → Fixed -
Returns this -
subtration
-
operator /(
Fixed divisor) → Fixed -
Returns this /
divisor
-
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 divisor) → Fixed -
Returns the this ~/
divisor