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

maxintfloat should return an ::Integer #29297

Closed
tpapp opened this issue Sep 21, 2018 · 4 comments
Closed

maxintfloat should return an ::Integer #29297

tpapp opened this issue Sep 21, 2018 · 4 comments
Labels
docs This change adds or pertains to documentation maths Mathematical functions

Comments

@tpapp
Copy link
Contributor

tpapp commented Sep 21, 2018

Contrary to its documentation which says (emphasis mine)

... maxintfloat returns the smallest positive integer ...

it actually returns floating point values.

I don't know if this is a problem with wording or the implementation. IMO returning integers would be more useful as one could perform exact arithmetic & comparisons with them around the edge of the representable region.

@StefanKarpinski
Copy link
Sponsor Member

The word "integer" is a bit ambiguous in this case it means "integer-valued floating point number", so we could replace the word with that in the docs. Changing the type returned would be a breaking change, so we're not going to do that but you can easily just do Int(maxintfloat()) to get an integer.

@StefanKarpinski StefanKarpinski added docs This change adds or pertains to documentation maths Mathematical functions labels Sep 21, 2018
@tpapp
Copy link
Contributor Author

tpapp commented Sep 21, 2018

Not quite, eg maxintfloat(BigFloat), but Integer(maxintfloat(...)) seems to do the trick.

I will make a PR about the documentation then, and perhaps mention this?

@StefanKarpinski
Copy link
Sponsor Member

Yes, that would be great!

tpapp added a commit to tpapp/julia that referenced this issue Sep 21, 2018
@JeffBezanson
Copy link
Sponsor Member

I think it makes sense to return special values of a type as that type itself. Improving the docs sounds like the right thing here.

JeffBezanson pushed a commit that referenced this issue Sep 24, 2018
KristofferC pushed a commit that referenced this issue Sep 30, 2018
Fixes #29297, see discussion there.

(cherry picked from commit 64a4f18)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Fixes #29297, see discussion there.

(cherry picked from commit 64a4f18)
KristofferC pushed a commit that referenced this issue Feb 20, 2020
Fixes #29297, see discussion there.

(cherry picked from commit 64a4f18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation maths Mathematical functions
Projects
None yet
Development

No branches or pull requests

3 participants