Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions numbers/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func DecimalExp(dec string, exp int) string {
i -= origSize - len(dec)
// Fix bounds
if i <= 0 {
zeros := ""
var zeros strings.Builder
for ; i < 0; i++ {
zeros += "0"
zeros.WriteString("0")
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using WriteByte('0') instead of WriteString("0") for better performance when appending a single character. WriteByte is more efficient than WriteString for single-byte operations.

Suggested change
zeros.WriteString("0")
zeros.WriteByte('0')

Copilot uses AI. Check for mistakes.
}
return "0." + zeros + dec
return "0." + zeros.String() + dec
} else if i >= len(dec) {
for i > len(dec) {
dec += "0"
Expand All @@ -82,8 +82,8 @@ func HexToDecimal(hex string) (string, error) {

// CutZeroFractional cuts off a decimal separator and zeros to the right.
// Fails if the fractional part contains contains other digits than zeros.
// - CutZeroFractional("123.00000") => ("123", true)
// - CutZeroFractional("123.456") => ("", false)
// - CutZeroFractional("123.00000") => ("123", true)
// - CutZeroFractional("123.456") => ("", false)
func CutZeroFractional(dec string) (integer string, ok bool) {
// Get comma position
comma := strings.IndexRune(dec, '.')
Expand Down