You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following are the four number types and their corresponding number type bytecode supported by the standard deviation filter:
int32 (0x00)
int64 (0x01)
uint32 (0x02)
uint64 (0x03): Not fully supported because the ojg package converts large numbers to json.Number. which we do not deal with in the standard filter yet.
First, we need to add a full support for uint64 by parsing json.Number. We can make use of the generic type as follows:
num, ok := data.(int64)
if !ok {
// Big numbers are stored as json.Number.
bigNum, ok := data.(json.Number)
if !ok {
corruptQueue = append(corruptQueue, i)
continue
}
var num T
var err error
rt := reflect.TypeOf(num)
switch rt.Kind() {
case reflect.Int32, reflect.Int64:
var t int64
t, err = strconv.ParseInt(bigNum.String(), 10, rt.Bits())
num = T(t)
case reflect.Uint32, reflect.Uint64:
var t uint64
t, err = strconv.ParseUint(bigNum.String(), 10, rt.Bits())
num = T(t)
default:
return nil, ErrFilterUnexpected // should not be reachable
}
if err != nil {
corruptQueue = append(corruptQueue, i)
continue
}
nums = append(nums, T(num))
}
Second, we need to clarify in the specifications the number ranges we support and possible overflow issues. We should perhaps add an overflow detection wherever it can happen such as when we cast number types or compute the median.
Third, we will add support for math/big numbers, which provide arbitrary-precision arithmetics.
The text was updated successfully, but these errors were encountered:
✨ Feature
The following are the four number types and their corresponding number type bytecode supported by the standard deviation filter:
int32
(0x00
)int64
(0x01
)uint32
(0x02
)uint64
(0x03
): Not fully supported because the ojg package converts large numbers tojson.Number
. which we do not deal with in the standard filter yet.First, we need to add a full support for
uint64
by parsingjson.Number
. We can make use of the generic type as follows:Second, we need to clarify in the specifications the number ranges we support and possible overflow issues. We should perhaps add an overflow detection wherever it can happen such as when we cast number types or compute the median.
Third, we will add support for
math/big
numbers, which provide arbitrary-precision arithmetics.The text was updated successfully, but these errors were encountered: