read method
Formats the given value
as a Readable instance using the numeric unit.
If the unit is auto, it automatically determines the most appropriate
unit based on the value
.
Example:
Readable readable = NumberUnits.m.read(1500000);
print(readable); // Output: 1.5 M
Implementation
Readable read(num? value) {
value ??= 0;
if (this == auto) {
if (value <= 0) return Readable(0, none.name);
final i = (value == 0) ? 0 : (log(value) / log(1000)).floor();
final u = this[i];
return Readable(value / u.unit, u.name, 1);
} else {
return Readable(value / unit, name, 1);
}
}