-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Fix exp10 fallback and exp2 and exp10 for Float16 #22716
Conversation
test/math.jl
Outdated
@@ -661,3 +661,17 @@ end | |||
@test sincos(big(1)) == (sin(big(1)), cos(big(1))) | |||
@test sincos(big(1.0)) == (sin(big(1.0)), cos(big(1.0))) | |||
end | |||
|
|||
@testset "Float16 fallbacks" begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps integrate with
Line 252 in e5cc4d7
@test exp2(Float16(2.)) ≈ exp2(2.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
base/math.jl
Outdated
@@ -263,14 +263,27 @@ cbrt(x::AbstractFloat) = x < 0 ? -(-x)^(1//3) : x^(1//3) | |||
""" | |||
exp2(x) | |||
|
|||
Compute ``2^x``. | |||
Compute the base `2` exponential of `x`, in other words ``2^x``. | |||
|
|||
```jldoctest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Examples
```jldoctest
base/math.jl
Outdated
|
||
Compute the base `10` exponential of `x`, in other words ``10^x``. | ||
|
||
```jldoctest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Examples
```jldoctest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks will fix later
test/math.jl
Outdated
end | ||
|
||
# test AbstractFloat fallback | ||
struct Float32432{T<:AbstractFloat} <: AbstractFloat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this number referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing, just a random string of numbers so it doesn't clash with another name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the issue number or a word, less confusing that way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change to use the PR number since I didn't open an issue for this
Appveyor looks missing, restarting |
Anything else to do here? |
base/math.jl
Outdated
@@ -263,14 +263,29 @@ cbrt(x::AbstractFloat) = x < 0 ? -(-x)^(1//3) : x^(1//3) | |||
""" | |||
exp2(x) | |||
|
|||
Compute ``2^x``. | |||
Compute the base `2` exponential of `x`, in other words ``2^x``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 should probably not be code highlighted? Likewise 10 in the docstring below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a harm in highlighting the number, maybe others have a different thought on this? Will update accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think it needs it for just the number on its own
* Fix exp10 fallback and exp2 and exp10 for Float16 * Update docstring and test * Change float struct name * Update math.jl
* Fix exp10 fallback and exp2 and exp10 for Float16 * Update docstring and test * Change float struct name * Update math.jl (cherry picked from commit 3ff6eac)
exp2
was not added to the Float16 definitions and hence calls the very slow fallback to2^x
.exp10
does not have any fallback definitions and thus things likelead to a StackOverFlow or with other
AbstractFloat