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

jfcg opened this issue Apr 26, 2016 · 2 comments

builtin: new function: abs() #15447

jfcg opened this issue Apr 26, 2016 · 2 comments


Copy link

@jfcg 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

abs(pointer) returns value of pointer as uintptr

Copy link

@bradfitz bradfitz commented Apr 26, 2016

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, etc.

@bradfitz bradfitz closed this Apr 26, 2016
Copy link

@kafeltz 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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants