From 23985376318b2a9bea31da242d3488a29f59395d Mon Sep 17 00:00:00 2001 From: Udoh Jeremiah Date: Tue, 20 Sep 2022 04:38:18 +0100 Subject: [PATCH] clear info on the exponent function (#46815) Co-authored-by: Daniel Karrasch --- base/math.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/base/math.jl b/base/math.jl index 09ded65bcddb84..968eb0eee8bc01 100644 --- a/base/math.jl +++ b/base/math.jl @@ -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