ByteRounding class abstract

Extended rounding strategies for byte value formatting.

Provides additional rounding methods beyond the standard round, floor, and ceil operations, including banker's rounding and various tie-breaking strategies.

Example:

final value = 1.5;
print(ByteRounding.round(value, precision: 0));      // 2.0
print(ByteRounding.floor(value, precision: 0));      // 1.0
print(ByteRounding.ceil(value, precision: 0));       // 2.0
print(ByteRounding.truncate(value, precision: 0));   // 1.0
print(ByteRounding.halfUp(value, precision: 0));     // 2.0
print(ByteRounding.halfEven(value, precision: 0));   // 2.0 (banker's)

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

ceil(double value, {int precision = 2}) double
Rounds toward positive infinity.
floor(double value, {int precision = 2}) double
Rounds toward negative infinity.
halfAwayFromZero(double value, {int precision = 2}) double
Rounds halves away from zero.
halfDown(double value, {int precision = 2}) double
Rounds halves down (toward negative infinity).
halfEven(double value, {int precision = 2}) double
Banker's rounding (rounds halves to nearest even).
halfTowardZero(double value, {int precision = 2}) double
Rounds halves toward zero.
halfUp(double value, {int precision = 2}) double
Rounds halves up (toward positive infinity).
round(double value, {int precision = 2}) double
Standard rounding (rounds halves away from zero).
truncate(double value, {int precision = 2}) double
Rounds toward zero (truncation).
withMode(double value, {int precision = 2, ByteRoundingMode mode = ByteRoundingMode.round}) double
Rounds using the specified RoundingMode.