diff --git a/base/deprecated.jl b/base/deprecated.jl index cedc68e0e2a92f..fee8cb50b66708 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1342,6 +1342,22 @@ end @deprecate srand(filename::AbstractString, n::Integer=4) srand(read!(filename, Array{UInt32}(Int(n)))) @deprecate MersenneTwister(filename::AbstractString) srand(MersenneTwister(0), read!(filename, Array{UInt32}(Int(4)))) +# 22031 +function hex2num(s::AbstractString) + depwarn("hex2num(s) is deprecated. Use reinterpret(Float64, parse(UInt64, s, 16)) instead.", :hex2num) + if length(s) <= 4 + return reinterpret(Float16, parse(UInt16, s, 16)) + end + if length(s) <= 8 + return reinterpret(Float32, parse(UInt32, s, 16)) + end + return reinterpret(Float64, parse(UInt64, s, 16)) +end + +@deprecate num2hex(x::Union{Float16,Float32,Float64}) = + hex(reintepret(Unsigned, x), sizeof(x)*2) +@deprecate num2hex(n::Integer) = hex(n, sizeof(n)*2) + # END 0.7 deprecations # BEGIN 1.0 deprecations diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 622a02c1e3152a..3a4b8cca84f680 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -565,18 +565,6 @@ original string, otherwise they must be from distinct character ranges. """ eachmatch -""" - num2hex(f) - -Get a hexadecimal string of the binary representation of a floating point number. - -```jldoctest -julia> num2hex(2.2) -"400199999999999a" -``` -""" -num2hex - """ truncate(file,n) @@ -1360,13 +1348,6 @@ false """ isempty -""" - hex2num(str) - -Convert a hexadecimal string to the floating point number it represents. -""" -hex2num - """ InexactError() diff --git a/base/exports.jl b/base/exports.jl index 376a9704b6d559..df7efcd8ef865f 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -340,7 +340,6 @@ export gamma, gcd, gcdx, - hex2num, hypot, imag, inv, @@ -378,7 +377,6 @@ export nextpow2, nextprod, numerator, - num2hex, one, oneunit, powermod, diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index e75486a46257c5..30ff62e1790e65 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -24,20 +24,6 @@ maxintfloat() = maxintfloat(Float64) isinteger(x::AbstractFloat) = (x - trunc(x) == 0) -num2hex(x::Float16) = hex(bitcast(UInt16, x), 4) -num2hex(x::Float32) = hex(bitcast(UInt32, x), 8) -num2hex(x::Float64) = hex(bitcast(UInt64, x), 16) - -function hex2num(s::AbstractString) - if length(s) <= 4 - return bitcast(Float16, parse(UInt16, s, 16)) - end - if length(s) <= 8 - return bitcast(Float32, parse(UInt32, s, 16)) - end - return bitcast(Float64, parse(UInt64, s, 16)) -end - """ round([T,] x, [digits, [base]], [r::RoundingMode]) diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 50bb11bd47f591..01ad9d2dc2f45c 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -483,8 +483,6 @@ function hex(x::Unsigned, pad::Int, neg::Bool) String(a) end -num2hex(n::Integer) = hex(n, sizeof(n)*2) - const base36digits = ['0':'9';'a':'z'] const base62digits = ['0':'9';'A':'Z';'a':'z'] diff --git a/doc/src/stdlib/numbers.md b/doc/src/stdlib/numbers.md index 36ee7e5634d2ff..8f9941b94890f2 100644 --- a/doc/src/stdlib/numbers.md +++ b/doc/src/stdlib/numbers.md @@ -40,8 +40,6 @@ Base.Math.significand Base.Math.exponent Base.complex(::Complex) Base.bswap -Base.num2hex -Base.hex2num Base.hex2bytes Base.bytes2hex ```