Skip to content

Commit

Permalink
fix: printing rounded up numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
howeyc committed Apr 10, 2022
1 parent 62be50b commit 33fd1fa
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
6 changes: 1 addition & 5 deletions internal/decimal/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ func (d Decimal) StringFixedBank() string {
}

if frac >= 100 {
if sign == "" {
whole++
} else {
whole--
}
whole++
frac -= 100
}

Expand Down
60 changes: 60 additions & 0 deletions internal/decimal/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,66 @@ var testParseCases = []testCase{
"0.01",
"0.010e1",
},
{
"fuzz-7",
"-8.00",
"-7.995",
},
{
"fuzz-8",
"-9.00",
"-8.995",
},
{
"fuzz-9",
"8.00",
"7.995",
},
{
"fuzz-10",
"9.00",
"8.995",
},
{
"fuzz-11",
"-7.98",
"-7.985",
},
{
"fuzz-12",
"-8.98",
"-8.985",
},
{
"fuzz-13",
"7.98",
"7.985",
},
{
"fuzz-14",
"8.98",
"8.984",
},
{
"fuzz-15",
"-8.00",
"-7.999",
},
{
"fuzz-16",
"-9.00",
"-8.999",
},
{
"fuzz-17",
"8.00",
"7.999",
},
{
"fuzz-18",
"9.00",
"8.999",
},
{
"error-1",
"number too big",
Expand Down

0 comments on commit 33fd1fa

Please sign in to comment.