golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.39k stars 17.71k forks source link

add a decimal function #61378

Closed xiaokentrl closed 1 year ago

xiaokentrl commented 1 year ago

I would like to add a system function called decimal() that facilitates the calculation of integers, floating-point numbers, and negative numbers while developing code. Mathematical calculations have always been essential in computer systems, regardless of the programming language used. Therefore, mathematical calculations should not rely on third-party decimal packages but rather be integrated as a built-in system function in the Go programming language.

mvdan commented 1 year ago

Please note that you should fill https://github.com/golang/proposal/blob/master/go2-language-changes.md when proposing a language change.

ianlancetaylor commented 1 year ago

I'm sorry, I don't understand this proposal. Please at least give some examples.

Jorropo commented 1 year ago
func decimal[T ~float32 | ~float64](v T) T {
 return v % 1
}

:question:

gopherbot commented 1 year ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)