Back to Course
The Freebies
0% Complete
0/0 Steps
-
Ruby Language19 Topics
-
Ruby Core Objects and Datastructures8 Topics
-
Ruby Libraries8 Topics
-
Object-Oriented Concepts3 Topics
-
Testing3 Topics
-
Design, Evolution, and Refactoring6 Topics
-
Performance, Resilience, and Robustness2 Topics
-
Rake and Project Automation7 Topics
-
Functional Programming1 Topic
-
Sociotechnical Systems1 Topic
Module 1,
Topic 3
In Progress
Large Integer Literals
Module Progress
0% Complete
Continuing in this series about literals and quoting, let's talk about large integers.
Quick question: how many zeroes are in this number?
100000000000
Past a certain size, it's hard to visually identify the number of digits in a numeric literal. That's why in written language we usually break the number into groups of digits. For instance, in my US locale we would normally split the number into groups of three digits, with commas:
# 100,000,000,000
Thankfully, we can do something similar in Ruby. Ruby lets us insert underscores anywhere we want in integer literals. So we could rewrite this number like so:
100_000_000_000
And I think you'll agree that's a lot easier to visually parse.
That's all for today. Happy hacking!
Responses