Book Image

Getting Started with Julia

By : Ivo Balbaert
Book Image

Getting Started with Julia

By: Ivo Balbaert

Overview of this book

Table of Contents (19 chapters)
Getting Started with Julia
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Rationale for Julia
Index

Integers


Julia offers support for integer numbers ranging from types Int8 to Int128, with 8 to 128 representing the number of bits used, and with unsigned variants with a U prefix, such as UInt8. The default type (which can also be used as Int) is Int32 or Int64 depending on the target machine architecture. The bit width is given by the variable WORD_SIZE. The number of bits used by the integer affects the maximum and minimum value this integer can have. The minimum and maximum values are given by the functions typemin() and typemax() respectively, for example, typemax(Int16) returns 32767.

If you try to store a number larger than that allowed by typemax, overflow occurs. For example:

julia> typemax(Int)
9223372036854775807 # might be different on 32 bit platform
julia> ans + 1
-9223372036854775808

Overflow checking is not automatic, so an explicit check (for example, the result has the wrong sign) is needed when this can occur. Integers can also be written in binary (0b), octal (0o...