thinkeridea / go-extend

go语言扩展包,收集一些常用的操作函数,辅助更快的完成开发工作,并减少重复代码

Home Page:https://pkg.go.dev/github.com/thinkeridea/go-extend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG: Round(169543.34596, -5) == 199999.99999999997, want 200000

opened this issue · comments

This is indeed a difference in accuracy, I continue to look for other algorithms to ensure his results.

package main

import (
	"fmt"

	"github.com/thinkeridea/go-extend/exmath"
)

func main() {
	fmt.Println(exmath.Round(169543.34596, -5) == 200000.0) // false
	fmt.Printf("%f\n", exmath.Round(169543.34596, -5))      // 200000.000000
	fmt.Println(exmath.Round(169543.34596, -5))             // 199999.99999999997
}

@he11olx 该问题在 #15 中进行修复,针对 precision 采用不同的算法。

如未报告其它类似问题,该问题将在一周后关闭。