v0.0.380 exerr properly handle inf and nan floats
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m8s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m8s
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -667,6 +668,28 @@ func (v MetaValue) rawValueForJson() any {
|
||||
}
|
||||
return v.Value.(EnumWrap).ValueString
|
||||
}
|
||||
if v.DataType == MDTFloat32 {
|
||||
if math.IsNaN(float64(v.Value.(float32))) {
|
||||
return "float64::NaN"
|
||||
} else if math.IsInf(float64(v.Value.(float32)), +1) {
|
||||
return "float64::+inf"
|
||||
} else if math.IsInf(float64(v.Value.(float32)), -1) {
|
||||
return "float64::-inf"
|
||||
} else {
|
||||
return v.Value
|
||||
}
|
||||
}
|
||||
if v.DataType == MDTFloat64 {
|
||||
if math.IsNaN(v.Value.(float64)) {
|
||||
return "float64::NaN"
|
||||
} else if math.IsInf(v.Value.(float64), +1) {
|
||||
return "float64::+inf"
|
||||
} else if math.IsInf(v.Value.(float64), -1) {
|
||||
return "float64::-inf"
|
||||
} else {
|
||||
return v.Value
|
||||
}
|
||||
}
|
||||
return v.Value
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user