In [3]:
using Printf
function decode_Float64(x::Float64)
    s =  bitstring(x)
    sgn = parse(Int,s[1],base=2)
    e = parse(Int,s[2:12],base=2)
    f = parse(Int,s[13:64],base=2)
    ffrac = f/2^52
    
    ebias = 1023
    
    fstr = (@sprintf( "%.17f", ffrac) )[3:end]
    
    if e == 0
        println( @sprintf(" (-1)^(%i) x 2^(%i) x 0.%s = %g ", sgn, 1-ebias, fstr, x) )
    elseif e == 2^11 - 1
        println( @sprintf(" (-1)^(%i) x 2^(Inf) x 1.%s = %g ", sgn, fstr, x) )
    else
        println( @sprintf(" (-1)^(%i) x 2^(%i) x 1.%s = %g ", sgn, e-ebias, fstr, x) )
    end
end

decode_Float64(Inf)
decode_Float64(NaN)
decode_Float64(0. / 0.)
decode_Float64(-Inf)
decode_Float64(-Inf + Inf)
decode_Float64(reinterpret(Float64,0x000fffffffffffff))
decode_Float64(1.)
decode_Float64(nextfloat(1.))
decode_Float64(prevfloat(1.))
decode_Float64(-prevfloat(1.))
 (-1)^(0) x 2^(Inf) x 1.00000000000000000 = Inf 
 (-1)^(0) x 2^(Inf) x 1.50000000000000000 = NaN 
 (-1)^(1) x 2^(Inf) x 1.50000000000000000 = NaN 
 (-1)^(1) x 2^(Inf) x 1.00000000000000000 = -Inf 
 (-1)^(1) x 2^(Inf) x 1.50000000000000000 = NaN 
 (-1)^(0) x 2^(-1022) x 0.99999999999999978 = 2.22507e-308 
 (-1)^(0) x 2^(0) x 1.00000000000000000 = 1 
 (-1)^(0) x 2^(0) x 1.00000000000000022 = 1 
 (-1)^(0) x 2^(-1) x 1.99999999999999978 = 1 
 (-1)^(1) x 2^(-1) x 1.99999999999999978 = -1 
In [ ]:

In [6]:
setprecision(BigFloat,3)
setrounding(BigFloat,RoundDown)
x = big"1.0"
for i=1:25
    x = nextfloat(x)
    @show x
end
x = 1.2
x = 1.5
x = 1.8
x = 2.0
x = 2.5
x = 3.0
x = 3.5
x = 4.0
x = 5.0
x = 6.0
x = 7.0
x = 8.0
x = 10.0
x = 12.0
x = 14.0
x = 16.0
x = 20.0
x = 24.0
x = 28.0
x = 32.0
x = 40.0
x = 48.0
x = 56.0
x = 64.0
x = 80.0
In [7]:
decode_Float64(Inf - Inf)
 (-1)^(1) x 2^(Inf) x 1.50000000000000000 = NaN 
In [10]:
decode_Float64(1.)
decode_Float64(nextfloat(1.))
println( bitstring(1.) )
println(  bitstring(nextfloat(1.)) )

@show eps(1.)
@show 2. ^(-52.)
 (-1)^(0) x 2^(0) x 1.00000000000000000 = 1 
 (-1)^(0) x 2^(0) x 1.00000000000000022 = 1 
0011111111110000000000000000000000000000000000000000000000000000
0011111111110000000000000000000000000000000000000000000000000001
eps(1.0) = 2.220446049250313e-16
2.0 ^ -52.0 = 2.220446049250313e-16
Out[10]:
2.220446049250313e-16
In [ ]: