Hi! I wanted to ask what is the difference between the current
implementation of math.Abs and the following:
```go
func Abs(x float64) float64 {
if x < 0 {
return -x
}
return x
}
```
math.Abs would appear to return a copy of the input with the sign bit set
to zero. I tried the special conditions of NaN (the one returned by
math.NaN()), +Inf, and -Inf and the above would appear to work the same.
I guess my main question is: would "-x" behave differently under any
condition? Was there a particular motivation for the current
implementation? Not judging nor asking for any change, just trying to learn.
Thank you!
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/0cffdc6f-65c3-45c1-b003-ef3c27a0542en%40googlegroups.com.