Now we will consider how to handle real and complex numbers in Julia and also introduce an alternate representation of fixed-point reals as a fraction comprising two integers, the Rational
datatype.
Further we will discuss the use of the Big()
function to handle integers and real numbers which are too large to be represented by the primitive Julia numeric types.
We have met real numbers a few times already. The generic type is FloatingPoint
which is sub-classed from Real
:
abstract Real <: Number abstract FloatingPoint <: Real bitstype 16 Float16 <: FloatingPoint bitstype 32 Float32 <: FloatingPoint bitstype 64 Float64 <: FloatingPoint
A float can be defined as x = 100.0
or x = 1e2
or x = 1f2
; all represent the number 100
.
The first will be of the type equivalent to WORD_SIZE
, the second of type Float64
and the third (using f
rather than the e
notation) of type Float32
.
There is also a p
notation which can be used with hexadecimals, that is...