Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Julia

You're reading from   Learning Julia Build high-performance applications for scientific computing

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781785883279
Length 316 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Rahul Lakhanpal Rahul Lakhanpal
Author Profile Icon Rahul Lakhanpal
Rahul Lakhanpal
Anshul Joshi Anshul Joshi
Author Profile Icon Anshul Joshi
Anshul Joshi
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Understanding Julia's Ecosystem FREE CHAPTER 2. Programming Concepts with Julia 3. Functions in Julia 4. Understanding Types and Dispatch 5. Working with Control Flow 6. Interoperability and Metaprogramming 7. Numerical and Scientific Computation with Julia 8. Data Visualization and Graphics 9. Connecting with Databases 10. Julia’s Internals

Floating point numbers in Julia


It is easy to represent floating point numbers in Julia. They are represented in a similar fashion as they are in other languages:

# Add a decimal point
julia> 100.0
100.0

julia> 24.
24.0

# It is not required to precede a number from the decimal point
julia> .10
0.1

julia> typeof(ans)
Float64

There is a concept of positive zero and negative zero in Julia. They are equal but with different binary representations:

# equating two zeroes
julia> 0.0 == -0.0
true

julia> bits(0.0)
"0000000000000000000000000000000000000000000000000000000000000000"

# different first bit for negative zero
julia> bits(-0.0)
"1000000000000000000000000000000000000000000000000000000000000000"

Exponential notation can be very useful and convenient in various scenarios. It can be used in Julia using e:

julia> 2.99e8
2.99e8

julia> 2.99e8>999999
true

We have been using Float64 in the preceding examples. We can also use Float32 on 64-bit computers if required:

#...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime