mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Changed comment on ScaledValue (#79738)
* Changed comment on ScaledValue and added additional test * Added example to comment
This commit is contained in:
parent
5257266e9b
commit
e861a8bf34
@ -697,7 +697,9 @@ func (q *Quantity) MilliValue() int64 {
|
||||
return q.ScaledValue(Milli)
|
||||
}
|
||||
|
||||
// ScaledValue returns the value of ceil(q * 10^scale); this could overflow an int64.
|
||||
// ScaledValue returns the value of ceil(q / 10^scale).
|
||||
// For example, NewQuantity(1, DecimalSI).ScaledValue(Milli) returns 1000.
|
||||
// This could overflow an int64.
|
||||
// To detect overflow, call Value() first and verify the expected magnitude.
|
||||
func (q *Quantity) ScaledValue(scale Scale) int64 {
|
||||
if q.d.Dec == nil {
|
||||
|
@ -1029,6 +1029,7 @@ func TestScaledValue(t *testing.T) {
|
||||
{0, Micro, 1000 * 1000},
|
||||
{0, Milli, 1000},
|
||||
{0, 0, 1},
|
||||
{2, -2, 100 * 100},
|
||||
}
|
||||
|
||||
for _, item := range table {
|
||||
|
Loading…
Reference in New Issue
Block a user