21
0
Fork 0

v0.0.380 exerr properly handle inf and nan floats
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m8s Details

This commit is contained in:
Mike Schwörer 2024-01-22 12:33:41 +01:00
parent b9d0348735
commit 890e16241d
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 25 additions and 2 deletions

View File

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

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.379"
const GoextVersion = "0.0.380"
const GoextVersionTimestamp = "2024-01-19T17:30:20+0100"
const GoextVersionTimestamp = "2024-01-22T12:33:41+0100"