mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: bump k8s.io/api
Bumps the k8s-dependencies group with 1 update in the /api directory: [k8s.io/api](https://github.com/kubernetes/api). Updates `k8s.io/api` from 0.31.3 to 0.32.1 - [Commits](https://github.com/kubernetes/api/compare/v0.31.3...v0.32.1) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
8a66575825
commit
5aef21ea4e
39
api/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
39
api/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@ -20,7 +20,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
math "math"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -460,9 +460,10 @@ func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
// AsApproximateFloat64 returns a float64 representation of the quantity which may
|
||||
// lose precision. If the value of the quantity is outside the range of a float64
|
||||
// +Inf/-Inf will be returned.
|
||||
// AsApproximateFloat64 returns a float64 representation of the quantity which
|
||||
// may lose precision. If precision matter more than performance, see
|
||||
// AsFloat64Slow. If the value of the quantity is outside the range of a
|
||||
// float64 +Inf/-Inf will be returned.
|
||||
func (q *Quantity) AsApproximateFloat64() float64 {
|
||||
var base float64
|
||||
var exponent int
|
||||
@ -480,6 +481,36 @@ func (q *Quantity) AsApproximateFloat64() float64 {
|
||||
return base * math.Pow10(exponent)
|
||||
}
|
||||
|
||||
// AsFloat64Slow returns a float64 representation of the quantity. This is
|
||||
// more precise than AsApproximateFloat64 but significantly slower. If the
|
||||
// value of the quantity is outside the range of a float64 +Inf/-Inf will be
|
||||
// returned.
|
||||
func (q *Quantity) AsFloat64Slow() float64 {
|
||||
infDec := q.AsDec()
|
||||
|
||||
var absScale int64
|
||||
if infDec.Scale() < 0 {
|
||||
absScale = int64(-infDec.Scale())
|
||||
} else {
|
||||
absScale = int64(infDec.Scale())
|
||||
}
|
||||
pow10AbsScale := big.NewInt(10)
|
||||
pow10AbsScale = pow10AbsScale.Exp(pow10AbsScale, big.NewInt(absScale), nil)
|
||||
|
||||
var resultBigFloat *big.Float
|
||||
if infDec.Scale() < 0 {
|
||||
resultBigInt := new(big.Int).Mul(infDec.UnscaledBig(), pow10AbsScale)
|
||||
resultBigFloat = new(big.Float).SetInt(resultBigInt)
|
||||
} else {
|
||||
pow10AbsScaleFloat := new(big.Float).SetInt(pow10AbsScale)
|
||||
resultBigFloat = new(big.Float).SetInt(infDec.UnscaledBig())
|
||||
resultBigFloat = resultBigFloat.Quo(resultBigFloat, pow10AbsScaleFloat)
|
||||
}
|
||||
|
||||
result, _ := resultBigFloat.Float64()
|
||||
return result
|
||||
}
|
||||
|
||||
// AsInt64 returns a representation of the current value as an int64 if a fast conversion
|
||||
// is possible. If false is returned, callers must use the inf.Dec form of this quantity.
|
||||
func (q *Quantity) AsInt64() (int64, bool) {
|
||||
|
Reference in New Issue
Block a user