O'Reilly logo

Mastering Julia by Malcolm Sherrington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required