The elements in the uninitialised array / vector?

This is probably a simple question. The code is this:
julia> Vector{Float64}(undef,3)

The output:

3-element Array{Float64,1}:
6.92297776986275e-310
6.92297776986354e-310
6.92297776986433e-310

I do not know what is exactly the meaning of the elements in the output of the 3-element Array. Are they randomly given or? I thought the vector is uninitialized, right?

I’m not in the computer right now, but I think that is the representation of a float64 of the bit value 0000000...000, you can try with println(bitstring(x[1])) to see what’s happening. About why 64 zero bits have that representation… I don’t know, that’s how floating point works :man_shrugging:

1 Like
julia> a=Vector{Float64}(undef,3)
3-element Array{Float64,1}:
 2.219358699e-314
 2.21936164e-314
 2.2085939415e-314

julia> println(bitstring(a[1]))
0000000000000000000000000000000100001011101111101111100000010000

I changed to my MAC book pro and the above is the code. Does this seem reasonable?

From Wikipedia, the first bit is the sign, the bites 2-12 are the exponent, and the rest are significant digits, so it makes sense

That is correct and the numbers you see are what happened to be in the memory that got allocated.

4 Likes