Code change:
} } <ins> func TestMul(t *testing.T) { tests := []struct { a        Quantity b        int64 expected Quantity ok       bool }{ {decQuantity(10, 0, DecimalSI), 10, decQuantity(100, 0, DecimalSI), true}, {decQuantity(10, 0, DecimalSI), 1, decQuantity(10, 0, DecimalSI), true}, {decQuantity(10, 0, BinarySI), 1, decQuantity(10, 0, BinarySI), true}, {Quantity{Format: DecimalSI}, 50, decQuantity(0, 0, DecimalSI), true}, {decQuantity(50, 0, DecimalSI), 0, decQuantity(0, 0, DecimalSI), true}, {Quantity{Format: DecimalSI}, 0, decQuantity(0, 0, DecimalSI), true}, {decQuantity(10, 0, DecimalSI), -10, decQuantity(-100, 0, DecimalSI), true}, {decQuantity(-10, 0, DecimalSI), 1, decQuantity(-10, 0, DecimalSI), true}, {decQuantity(10, 0, BinarySI), -1, decQuantity(-10, 0, BinarySI), true}, {decQuantity(-50, 0, DecimalSI), 0, decQuantity(0, 0, DecimalSI), true}, {decQuantity(-50, 0, DecimalSI), -50, decQuantity(2500, 0, DecimalSI), true}, {Quantity{Format: DecimalSI}, -50, decQuantity(0, 0, DecimalSI), true}, {decQuantity(mostPositive, 0, DecimalSI), 0, decQuantity(0, 1, DecimalSI), true}, {decQuantity(mostPositive, 0, DecimalSI), 1, decQuantity(mostPositive, 0, DecimalSI), true}, {decQuantity(mostPositive, 0, DecimalSI), -1, decQuantity(-mostPositive, 0, DecimalSI), true}, {decQuantity(mostPositive/2, 0, DecimalSI), 2, decQuantity((mostPositive/2)*2, 0, DecimalSI), true}, {decQuantity(mostPositive/-2, 0, DecimalSI), -2, decQuantity((mostPositive/2)*2, 0, DecimalSI), true}, {decQuantity(mostPositive, 0, DecimalSI), 2, bigDecQuantity(big.NewInt(0).Mul(bigMostPositive, big.NewInt(2)), 0, DecimalSI), false}, {decQuantity(mostPositive, 0, DecimalSI), 10, decQuantity(mostPositive, 1, DecimalSI), false}, {decQuantity(mostPositive, 0, DecimalSI), -10, decQuantity(-mostPositive, 1, DecimalSI), false}, {decQuantity(mostNegative, 0, DecimalSI), 0, decQuantity(0, 1, DecimalSI), true}, {decQuantity(mostNegative, 0, DecimalSI), 1, decQuantity(mostNegative, 0, DecimalSI), true}, {decQuantity(mostNegative, 0, DecimalSI), -1, bigDecQuantity(big.NewInt(0).Add(bigMostPositive, big.NewInt(1)), 0, DecimalSI), false}, {decQuantity(mostNegative/2, 0, DecimalSI), 2, decQuantity(mostNegative, 0, DecimalSI), true}, {decQuantity(mostNegative/-2, 0, DecimalSI), -2, decQuantity(mostNegative, 0, DecimalSI), true}, {decQuantity(mostNegative, 0, DecimalSI), 2, bigDecQuantity(big.NewInt(0).Mul(bigMostNegative, big.NewInt(2)), 0, DecimalSI), false}, {decQuantity(mostNegative, 0, DecimalSI), 10, decQuantity(mostNegative, 1, DecimalSI), false}, {decQuantity(mostNegative, 0, DecimalSI), -10, bigDecQuantity(big.NewInt(0).Add(bigMostPositive, big.NewInt(1)), 1, DecimalSI), false}, } for i, test := range tests { if ok := test.a.Mul(test.b); test.ok != ok { t.Errorf("[%d] Expected ok: %t, got ok: %t", i, test.ok, ok) } if test.a.Cmp(test.expected) != 0 { t.Errorf("[%d] Expected %q, got %q", i, test.expected.AsDec().String(), test.a.AsDec().String()) } } } </ins> func TestAddSubRoundTrip(t *testing.T) { for k := -10; k <= 10; k++ { q := Quantity{Format: DecimalSI}

Related discussion:
text: I'd like to add a multiplication method for the resource.Quantity. Currently, the resource package provides helper methods to calculate Quantity, such as and : Batch workloads often replicate the same PodTemplate, and controllers calculate the resources needed for all containers. In that case, It is inconvenient to call the function as many times as podTemplate, so I would like to create a helper function for multiplication.
/cc /sig api-machinary /wg batch
The label(s) cannot be applied, because the repository doesn't have them. <detailsIn response to : /cc /sig api-machinary /wg batch </details
/sig api-machinery /wg batch
Do you have an example of usage for these utilities? Just curious?
/triage accepted
Sorry for the late response. Taking k-sigs/kueue as an example, I assumed the below: It helps the controllers for batch workloads such as k-sigs/kueue, k-sigs/jobset, kubeflow/mpi-operator, and kubeflow/training-operator. I'm thinking of implementing this function once the code freeze term is finished.
/assign
Hi, may i take this up?
I took this one, and working on this now.