Skip to content

Commit

Permalink
clear info on the exponent function (#46815)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Karrasch <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 21, 2023
1 parent 15541cd commit 2398537
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -930,18 +930,27 @@ end
ldexp(x::Float16, q::Integer) = Float16(ldexp(Float32(x), q))

"""
exponent(x::AbstractFloat) -> Int
exponent(x) -> Int
Get the exponent of a normalized floating-point number.
Returns the largest integer `y` such that `2^y ≤ abs(x)`.
For a normalized floating-point number `x`, this corresponds to the exponent of `x`.
# Examples
```jldoctest
julia> exponent(8)
3
julia> exponent(64//1)
6
julia> exponent(6.5)
2
julia> exponent(16.0)
4
julia> exponent(3.142e-4)
-12
```
"""
function exponent(x::T) where T<:IEEEFloat
Expand Down

0 comments on commit 2398537

Please sign in to comment.