In [1]:
include("float-help.jl")
In [2]:
a = 1/3
b = 2/3
@show_float a+b
println()
The computer representation of a + b is:
  0011111111110000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     01111111111   0000000000000000000000000000000000000000000000000000
= (-1)^(0) x 2^(   +0)   x 1.00000000000000000 = 1  

In [3]:
a = 3/10
b = 4/10
@show_float a+b
The computer representation of a + b is:
  0011111111100110011001100110011001100110011001100110011001100110
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     01111111110   0110011001100110011001100110011001100110011001100110
= (-1)^(0) x 2^(   -1)   x 1.39999999999999991 = 0.7 
In [4]:
@show_float Inf
The computer representation of Inf is:
  0111111111110000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     11111111111   0000000000000000000000000000000000000000000000000000
= (-1)^(0) x 2^( Inf)   x 1.00000000000000000 = Inf 
In [5]:
@show_float NaN
The computer representation of NaN is:
  0111111111111000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     11111111111   1000000000000000000000000000000000000000000000000000
= (-1)^(0) x 2^( Inf)   x 1.50000000000000000 = NaN 
In [7]:
@show_float Float64(pi)
The computer representation of Float64(pi) is:
  0100000000001001001000011111101101010100010001000010110100011000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     10000000000   1001001000011111101101010100010001000010110100011000
= (-1)^(0) x 2^(   +1)   x 1.57079632679489656 = 3.14159 
In [8]:
@show_float -Inf
The computer representation of -Inf is:
  1111111111110000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     1     11111111111   0000000000000000000000000000000000000000000000000000
= (-1)^(1) x 2^( Inf)   x 1.00000000000000000 = -Inf 
In [9]:
@show_float -NaN
The computer representation of -NaN is:
  1111111111111000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     1     11111111111   1000000000000000000000000000000000000000000000000000
= (-1)^(1) x 2^( Inf)   x 1.50000000000000000 = NaN 
In [10]:
@show_float 0.
The computer representation of 0.0 is:
  0000000000000000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     00000000000   0000000000000000000000000000000000000000000000000000
= (-1)^(0) x 2^(-1022)   x 0.00000000000000000 = 0  
In [11]:
@show_float -0.
The computer representation of -0.0 is:
  1000000000000000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     1     00000000000   0000000000000000000000000000000000000000000000000000
= (-1)^(1) x 2^(-1022)   x 0.00000000000000000 = -0  
In [12]:
@show_float(0.)
The computer representation of 0.0 is:
  0000000000000000000000000000000000000000000000000000000000000000
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     00000000000   0000000000000000000000000000000000000000000000000000
= (-1)^(0) x 2^(-1022)   x 0.00000000000000000 = 0  
In [13]:
@show_float nextfloat(0.)
The computer representation of nextfloat(0.0) is:
  0000000000000000000000000000000000000000000000000000000000000001
  which decodes to 
  | sign |   exponent  |    mantissa    
     0     00000000000   0000000000000000000000000000000000000000000000000001
= (-1)^(0) x 2^(-1022)   x 0.00000000000000022 = 4.94066e-324 
In [14]:
eps(1.)
Out[14]:
2.220446049250313e-16
In [15]:
eps()
Out[15]:
2.220446049250313e-16
In [16]:
eps(2.)
Out[16]:
4.440892098500626e-16
In [17]:
eps(0.)
Out[17]:
5.0e-324
In [18]:
nextfloat(Inf)
Out[18]:
Inf
In [19]:
nextfloat(-Inf)
Out[19]:
-1.7976931348623157e308
In [ ]: