-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version)?
Tip
- What operating system and processor architecture are you using (
go env)?
Doesn't matter
- What did you do?
The documentation for math.Ceil states:
Ceil returns the least integer value greater than or equal to x.
As far as I know, float representations of numbers can approximate integers but may not be land on them exactly. Also, as far as I know, casting a float to an integer always rounds down, e.g. int64(5.999999999) == 5.
I am worried there could be a situation where math.Ceil(N) could return a float like floor(N).999999999999999999, and this gets cast to an integer and returns a number lower than N. It would be nice if this was explicitly documented.
I'm also confused about why math.Ceil doesn't return an int64, though I'm sure there's a good reason for it. It would be nice if there was information about how to convert this value to an integer. (I am aware there are edge cases around large or small numbers, in this case I'm mostly worried about the values between 2^-30 and 2^30).