Skip to content

Commit

Permalink
Issue yuin#468 : change LNumber.String() from fmt.Sprint to strconv.F…
Browse files Browse the repository at this point in the history
…ormat(Int/Float)
  • Loading branch information
MrParano1d committed Dec 21, 2023
1 parent 2348fd0 commit e09d3f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"strconv"
)

type LValueType int
Expand Down Expand Up @@ -113,9 +114,9 @@ func (st LString) Format(f fmt.State, c rune) {

func (nm LNumber) String() string {
if isInteger(nm) {
return fmt.Sprint(int64(nm))
return strconv.FormatInt(int64(nm), 10)
}
return fmt.Sprint(float64(nm))
return strconv.FormatFloat(float64(nm), 'g', -1, 64)
}

func (nm LNumber) Type() LValueType { return LTNumber }
Expand Down

0 comments on commit e09d3f8

Please sign in to comment.