O'Reilly logo

Get Programming with Go by Nathan Youngman and Roger Peppé

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 6. Real numbers

After reading lesson 6, you’ll be able to

  • Use two types of real numbers
  • Understand the memory-versus-precision trade-off
  • Work around rounding errors in your piggy bank

Computers store and manipulate real numbers like 3.14159 using the IEEE-754 floating-point standard. Floating-point numbers can be very large or incredibly small: think galaxies and atoms. With such versatility, programming languages like JavaScript and Lua get by using floating-point numbers exclusively. Computers also support integers for whole numbers, the subject of the next lesson.

Consider this

Imagine a carnival game with three cups. The nearest cup is worth $0.10 to $1.00, the next is worth $1 to $10, and the farthest cup is worth ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required