Files
hash-wallet/cw_core/lib/amount/utils.dart
T
Konstantin UllrichandGitHub c838012979 Enhance Money class with precision handling and zero trimming (#3548)
* feat: enhance Money class with precision handling, scale alignment, and trailing zero trimming
2026-08-24 14:48:32 +02:00

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;
}