Skip to content

Commit fc97622

Browse files
Copilottobio
andcommitted
Use math.Round() for explicit rounding semantics
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
1 parent ab8f8ab commit fc97622

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/fleet/agent_policy/models.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package agent_policy
33
import (
44
"context"
55
"fmt"
6+
"math"
67
"slices"
78
"time"
89

@@ -142,7 +143,7 @@ func (model *agentPolicyModel) populateFromAPI(ctx context.Context, data *kbapi.
142143

143144
for _, rv := range *data.RequiredVersions {
144145
// Round the float32 percentage to nearest integer since we use Int32 in the schema
145-
percentage := int32(rv.Percentage + 0.5)
146+
percentage := int32(math.Round(float64(rv.Percentage)))
146147
versionMap[rv.Version] = types.Int32Value(percentage)
147148
}
148149

0 commit comments

Comments
 (0)