Floating point numbers in Julia
It is easy to represent floating point numbers in Julia. They are represented in a similar fashion as they are in other languages:
# Add a decimal point julia> 100.0 100.0 julia> 24. 24.0 # It is not required to precede a number from the decimal point julia> .10 0.1 julia> typeof(ans) Float64
There is a concept of positive zero and negative zero in Julia. They are equal but with different binary representations:
# equating two zeroes julia> 0.0 == -0.0 true julia> bits(0.0) "0000000000000000000000000000000000000000000000000000000000000000" # different first bit for negative zero julia> bits(-0.0) "1000000000000000000000000000000000000000000000000000000000000000"
Exponential notation can be very useful and convenient in various scenarios. It can be used in Julia using e
:
julia> 2.99e8 2.99e8 julia> 2.99e8>999999 true
We have been using Float64
in the preceding examples. We can also use Float32
on 64-bit computers if required:
#...