Book Image

Mastering Julia

Book Image

Mastering Julia

Overview of this book

Table of Contents (17 chapters)
Mastering Julia
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Integers, bits, bytes, and bools


Julia is a strongly typed language allowing the programmer to specify a variable's type precisely. However in common with most interpreted languages it does not require the type to be declared when a variable is declared, rather it infers it from the form of the declaration.

A variable in Julia is any combination of upper or lowercase letters, digits and the underscore (_) and exclamation (!) characters. It must start with a letter or an underscore _. Conventionally variable names consist of lowercase letters with long names separated by underscores rather than using camel case.

To determine a variable type we can use the typeof() function.

So typically:

julia>  x = 2;   typeof(x)  #  =>  gives Int64
julia>  x = 2.0;  typeof(x) # =>  gives Float64

Notice that the type (see the preceding code) starts with a capital letter and ends with a number which indicates the number of bit length of the variable. The bit length defaults to the word length of...