update dependencies (#6267)
Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
23
vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
generated
vendored
23
vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
generated
vendored
@@ -70,7 +70,6 @@ func (d Decimal128) String() string {
|
||||
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
|
||||
// Implicit 0b100 prefix in significand.
|
||||
exp = int(d.h >> 47 & (1<<14 - 1))
|
||||
//high = 4<<47 | d.h&(1<<47-1)
|
||||
// Spec says all of these values are out of range.
|
||||
high, low = 0, 0
|
||||
} else {
|
||||
@@ -152,21 +151,17 @@ func (d Decimal128) BigInt() (*big.Int, int, error) {
|
||||
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
|
||||
// Implicit 0b100 prefix in significand.
|
||||
exp = int(high >> 47 & (1<<14 - 1))
|
||||
//high = 4<<47 | d.h&(1<<47-1)
|
||||
// Spec says all of these values are out of range.
|
||||
high, low = 0, 0
|
||||
} else {
|
||||
// Bits: 1*sign 14*exponent 113*significand
|
||||
exp = int(high >> 49 & (1<<14 - 1))
|
||||
high = high & (1<<49 - 1)
|
||||
high &= (1<<49 - 1)
|
||||
}
|
||||
exp += MinDecimal128Exp
|
||||
|
||||
// Would be handled by the logic below, but that's trivial and common.
|
||||
if high == 0 && low == 0 && exp == 0 {
|
||||
if posSign {
|
||||
return new(big.Int), 0, nil
|
||||
}
|
||||
return new(big.Int), 0, nil
|
||||
}
|
||||
|
||||
@@ -328,6 +323,7 @@ func ParseDecimal128(s string) (Decimal128, error) {
|
||||
return dErr(s)
|
||||
}
|
||||
|
||||
// Parse the significand (i.e. the non-exponent part) as a big.Int.
|
||||
bi, ok := new(big.Int).SetString(intPart+decPart, 10)
|
||||
if !ok {
|
||||
return dErr(s)
|
||||
@@ -354,12 +350,25 @@ var (
|
||||
|
||||
// ParseDecimal128FromBigInt attempts to parse the given significand and exponent into a valid Decimal128 value.
|
||||
func ParseDecimal128FromBigInt(bi *big.Int, exp int) (Decimal128, bool) {
|
||||
//copy
|
||||
// copy
|
||||
bi = new(big.Int).Set(bi)
|
||||
|
||||
q := new(big.Int)
|
||||
r := new(big.Int)
|
||||
|
||||
// If the significand is zero, the logical value will always be zero, independent of the
|
||||
// exponent. However, the loops for handling out-of-range exponent values below may be extremely
|
||||
// slow for zero values because the significand never changes. Limit the exponent value to the
|
||||
// supported range here to prevent entering the loops below.
|
||||
if bi.Cmp(zero) == 0 {
|
||||
if exp > MaxDecimal128Exp {
|
||||
exp = MaxDecimal128Exp
|
||||
}
|
||||
if exp < MinDecimal128Exp {
|
||||
exp = MinDecimal128Exp
|
||||
}
|
||||
}
|
||||
|
||||
for bigIntCmpAbs(bi, maxS) == 1 {
|
||||
bi, _ = q.QuoRem(bi, ten, r)
|
||||
if r.Cmp(zero) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user