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 7. Whole numbers

After reading lesson 7, you’ll be able to

  • Use 10 types of whole numbers
  • Choose the right type
  • Use hexadecimal and binary representations

Go offers 10 different types for whole numbers, collectively called integers. Integers don’t suffer from the accuracy issues of floating-point types, but they can’t store fractional numbers and they have a limited range. The integer type you choose will depend on the range of values needed for a given situation.

Consider this

How many numbers can you represent with two tokens?

If the tokens are individually identifiable by position, there are four possible permutations. Both tokens, neither token, one token, or the other token. You could represent four numbers.

Computers ...

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