mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* feat: enhance Money class with precision handling, scale alignment, and trailing zero trimming
14 lines
349 B
Dart
14 lines
349 B
Dart
String trimTrailingFractionZeros(String value) {
|
|
if (!value.contains('.')) {
|
|
return value;
|
|
}
|
|
|
|
var end = value.length;
|
|
while (end > 0 && value[end - 1] == "0") {
|
|
end--;
|
|
}
|
|
|
|
final trimmed = end == value.length ? value : value.substring(0, end);
|
|
return trimmed.endsWith('.') ? trimmed.substring(0, trimmed.length - 1) : trimmed;
|
|
}
|