Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin: new function: abs() #15447

Closed
jfcg opened this issue Apr 26, 2016 · 2 comments
Closed

builtin: new function: abs() #15447

jfcg opened this issue Apr 26, 2016 · 2 comments

Comments

@jfcg
Copy link

jfcg commented Apr 26, 2016

Absolute value of a numeric value is very often needed in code, hence this is a proposal to add a builtin abs(). Proposed signature:

abs(constant) returns absolute value also as a constant
abs(unsigned integer) returns same value & type
abs(signed integer) returns absolute value as unsigned version of type
abs(float) returns absolute value & same type
abs(complex) returns absolute value as underlying float type

optional:
abs(pointer) returns value of pointer as uintptr

@bradfitz
Copy link
Contributor

The language is pretty frozen since 2012. I don't this meets the bar. It would also invite dozens more global functions, which isn't the type of language Go is.

It also is already served by https://golang.org/pkg/math/#Abs, https://golang.org/pkg/math/cmplx/#Abs etc.

@kafeltz
Copy link

kafeltz commented Apr 26, 2016

Is there abs() as a built-in function in another languages instead a external lib?
It feels so strange this request.

@golang golang locked and limited conversation to collaborators Apr 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants