Wednesday 20 January 2016

Julia: Floating point numbers

Julia support following floating-point types.
Type
Precision
Number Of Bits
Float16
half
16
Float32
single
32
Float64
double
64


julia> a=10.01
10.01

julia> typeof(a)
Float64


In addition to decimal point notation, you can also use 1.234e2, 1.234f2 to represent floating point numbers. ‘e’ notation is used to represent Float64 numbers, ‘f’ notation is used to represent Float32 numbers.
julia> a=123.4;

julia> b=1.234e2;

julia> c=1.234f2;

julia> a
123.4

julia> b
123.4

julia> c
123.4f0

julia> typeof(a)
Float64

julia> typeof(b)
Float64

julia> typeof(c)
Float32

Note:
While performing operations on Float16 numbers, these are promoted to Float32 by default.


Represent floating-point numbers in Hexadecimal notation
julia> 0x10p2
64.0

julia> 0x10p3
128.0

julia> 0x10p4
256.0

julia> 0x10p5
512.0







Previous                                                 Next                                                 Home

No comments:

Post a Comment