RoundingMode enum
Values
- ceil → const RoundingMode
-
Round toward positive infinity (equivalent to Math.ceil()).
Example: 2.1 -> 3, -2.1 -> -2.
- floor → const RoundingMode
-
Round toward negative infinity (equivalent to Math.floor()).
Example: 2.1 -> 2, -2.1 -> -3.
- expand → const RoundingMode
-
Round away from zero (increases magnitude). Equivalent to rounding up for positive numbers and rounding down for negative numbers.
Example: 2.1 -> 3, -2.1 -> -3.
- trunc → const RoundingMode
-
Round toward zero (decreases magnitude, equivalent to truncation). Equivalent to rounding down for positive numbers and rounding up for negative numbers.
Example: 2.1 -> 2, -2.1 -> -2.
- halfCeil → const RoundingMode
-
Round to the nearest neighbor. If equidistant (e.g., fractional part is .5), round toward positive infinity (standard "round half up" for positive numbers).
Example: 2.5 -> 3, -2.5 -> -2.
- halfFloor → const RoundingMode
-
Round to the nearest neighbor. If equidistant, round toward negative infinity.
Example: 2.5 -> 2, -2.5 -> -3.
- halfExpand → const RoundingMode
-
Round to the nearest neighbor. If equidistant, round away from zero (increases magnitude). This is the "commercial" rounding rule.
Example: 2.5 -> 3, -2.5 -> -3.
- halfTrunc → const RoundingMode
-
Round to the nearest neighbor. If equidistant, round toward zero (decreases magnitude).
Example: 2.5 -> 2, -2.5 -> -2.
- halfEven → const RoundingMode
-
Round to the nearest neighbor. If equidistant, round to the even neighbor (IEEE 754 "Round Half to Even"). This prevents statistical bias.
Example: 2.5 -> 2, 3.5 -> 4.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - 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
Constants
-
values
→ const List<
RoundingMode> - A constant List of the values in this enum, in order of their declaration.