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

transcendental functions return Float32 on small integer inputs #7390

Closed
simonster opened this issue Jun 23, 2014 · 4 comments
Closed

transcendental functions return Float32 on small integer inputs #7390

simonster opened this issue Jun 23, 2014 · 4 comments
Labels
needs decision A decision on this change is needed

Comments

@simonster
Copy link
Member

On line 124 of math.jl, we set up transcendental functions of arbitrary reals so that they call f(float(x)). Because float(::Int8) and float(::Int16) return a Float32, this means e.g. log(uint8(2)) returns a Float32. This is consistent, but I'm not sure it's desirable. The input is exact, so precision of the result seems just as important as if the input were an Int.

@JeffBezanson
Copy link
Sponsor Member

That's true; we might as well let 'Float64' be the "default" float type, and only use others when requested or when necessary.

@stevengj
Copy link
Member

Sounds reasonable to me. One of Kahan's standard "misconceptions of floating-point" is that "Arithmetic much more precise than the data it operates upon is needless, and wasteful," and it looks like we fell into that trap here by promoting integers by default to the narrowest fp type that can represent them exactly.

@StefanKarpinski
Copy link
Sponsor Member

My fault. Yes, we should just promote to Float64.

@ViralBShah
Copy link
Member

Yes Float64 should really be the default float type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision A decision on this change is needed
Projects
None yet
Development

No branches or pull requests

5 participants