mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
make dec formatting consistent with f64
This commit is contained in:
parent
3560498106
commit
59af059912
1 changed files with 11 additions and 6 deletions
|
@ -384,6 +384,10 @@ impl RocDec {
|
||||||
// push a dummy character so we have space for the decimal dot
|
// push a dummy character so we have space for the decimal dot
|
||||||
string.push('$');
|
string.push('$');
|
||||||
|
|
||||||
|
if decimal_location == last_nonzero_byte {
|
||||||
|
// never have a '.' as the last character
|
||||||
|
string.truncate(last_nonzero_byte)
|
||||||
|
} else {
|
||||||
// Safety: at any time, the string only contains ascii characters, so it is always valid utf8
|
// Safety: at any time, the string only contains ascii characters, so it is always valid utf8
|
||||||
let bytes = unsafe { string.as_bytes_mut() };
|
let bytes = unsafe { string.as_bytes_mut() };
|
||||||
|
|
||||||
|
@ -392,6 +396,7 @@ impl RocDec {
|
||||||
|
|
||||||
// and put in the decimal dot in the right place
|
// and put in the decimal dot in the right place
|
||||||
bytes[decimal_location] = b'.';
|
bytes[decimal_location] = b'.';
|
||||||
|
}
|
||||||
|
|
||||||
string.as_str()
|
string.as_str()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue