Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func marshalDecimal(b io.StringWriter, d float64) error {
rounded := math.RoundToEven(d/TH) * TH
i, _ := math.Modf(rounded)

if i < -999999999999 || i > 999999999999 {
if math.IsNaN(d) || i < -999999999999 || i > 999999999999 {
return ErrInvalidDecimal
}

Expand Down
2 changes: 2 additions & 0 deletions decimal_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package httpsfv

import (
"math"
"strings"
"testing"
)
Expand All @@ -24,6 +25,7 @@ func TestMarshalDecimal(t *testing.T) {
{-9999999999999.0, "", false},
{9999999999999.0, "", false},
{1.9, "1.9", true},
{math.NaN(), "", false},
}

var b strings.Builder
Expand Down
Loading