2 Julia as a calculator

 

This chapter covers

  • Working with integers, floating-point numbers, and fractions.
  • Using variables to store long numbers.
  • Create reusable calculations by defining functions.
  • The most basic types in Julia.

Even if you never end up using Julia as your primary language, you may still value it as a replacement for your desk calculator. Julia can even double as an advanced high school graphing calculator. As a bonus, it’s completely free to use.

Remember you got to walk before you can run, and exploring numbers is a great way to get introduced to the core concepts of Julia. Since Julia is not just a general-purpose programming language but specifically tailored towards numerical computing, manipulating numbers plays a unique role in Julia.

Figure 2.1. iOS Calculator application. Can we replace this with Julia?
calculator

In this chapter, we will look at the aspects of Julia that lets you do the same kinds of things in Julia that you would do with a calculator. Of course, you may object that you don’t intend to use Julia as a calculator, but this is simply a way to give you the foundation to understand the more complex topics.

2.1 The Julia Command Line

2.2 Constants and Variables

2.2.1 The Assignment Operator and Binding

2.2.2 The ans Variable

2.2.3 Literal Coefficients

2.3 Number Types And Bit-Length

2.3.1 Number Formats

2.3.2 Overflow, Signed and Unsigned Numbers

2.3.3 Floating-Point Numbers

2.3.4 Operations on Integers and Floating Point Numbers

2.4 Functions

2.4.1 Storing Functions in Files

2.4.2 Working with Functions in the REPL

2.4.3 Functions Everywhere

2.4.4 Functions to Work with Numbers

2.5 How to Use Numbers in Practice

sitemap