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 (figure 2.1). As a bonus, it’s completely free to use.

Remember you have 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 Retro scientific calculator. Can we replace the usage of a handheld calculator with a Julia REPL?
calculator

In this chapter, you will look at the aspects of Julia that let 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 Using constants and variables

2.2.1 Assigning and binding values to variables

2.2.2 Using the ans variable

2.2.3 What is a literal coefficient?

2.3 Different number types and their bit length in Julia

2.3.1 Writing numbers using different number formats

2.4 Floating-point numbers

2.4.1 Performing operations on integers and floating-point numbers

2.5 Defining functions

2.5.1 Storing function definitions in a file

2.5.2 Working with functions in the REPL

2.5.3 Functions everywhere

2.5.4 Functions to work with numbers

sitemap