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.
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 ...
Get Get Programming with Go now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.