Skip to content

Instantly share code, notes, and snippets.

@wubin1989
Created November 23, 2022 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wubin1989/497e0aa448b8e55c4aab5a0a961e7cad to your computer and use it in GitHub Desktop.
Save wubin1989/497e0aa448b8e55c4aab5a0a961e7cad to your computer and use it in GitHub Desktop.
func (receiver *GoStatsImpl) LargestRemainder(ctx context.Context, payload vo.PercentageReqVo) (data []vo.PercentageRespVo, err error) {
if len(payload.Data) == 0 {
return
}
input := make([]numberutils.Percentage, 0)
for _, item := range payload.Data {
input = append(input, numberutils.Percentage{
Value: item.Value,
Data: item.Key,
})
}
numberutils.LargestRemainder(input, int32(payload.Places))
for _, item := range input {
data = append(data, vo.PercentageRespVo{
Value: item.Value,
Key: item.Data.(string),
Percent: item.Percent,
PercentFormatted: item.PercentFormatted,
})
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment