Skip to content

numfmt result not correct #2164

@sunnyawake5

Description

@sunnyawake5

Description

value:1.1405000000000001
numfmtId:0(general)
format result:
excelize: 1.1405000000000001
excel:1.1405

Steps to reproduce the issue

option=&numfmt.DateOption{CultureInfo: numfmt.CultureNameZhCN}
value:="1.1405000000000001"
fmtId:="0"
date1904 := false
result:=""
// result := numfmt.Format(value, fmtCode, date1904, numfmt.CellTypeNumber, option)
// fmt.Println(result)

if fmtCode, ok := customfmts[fmtId]; ok {
	result = numfmt.Format(value, fmtCode, date1904, numfmt.CellTypeNumber, option)
	fmt.Println(result)
}else{
	numFmtID, _ := strconv.Atoi(fmtId)
	if fmtCode, ok := numfmt.GetBuiltInNumFmtCode(numFmtID, option); ok {
		result = numfmt.ApplyBuiltInNumFmt(option, value, fmtCode, numFmtID, date1904, numfmt.CellTypeNumber)
		fmt.Println(result)
	}else{
		fmt.Println(value)
	}
	
}

Describe the results you received

1.1405000000000001

Describe the results you expected

1.1405

Go version

1.24.1

Excelize version or commit ID

2.9

Environment

macos

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions