Real, complex, and rational numbers

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.

Reals

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 ...

Get Julia: High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.