Here's a preview from my zine, How Integers and Floats Work! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
big integers
integers don’t have to overflow
Instead, integers can expand to use more space as they get bigger. Integers that expand are called “big integers”.
big integer: I’m going to use ONE THOUSAND bytes of space!
big integer math is slower
It’s slower because it’s implemented in software, not hardware.
So a big integer addition is actually turned into lots of smaller additions.
how big integers are represented (in Go, as of 2023)
You can think of this array of 64-bit integers as being the number written in base 2^64
some languages only have big integers
Python 3 and Ruby: we’d rather have slower math and no weird overflow problems!
This works because people don’t do a lot of math in Ruby/Python (except with numpy, which doesn’t use big integers).
some languages offer big integers as an option
Go, Javascript, Java, and lots more. Each language has its own big integer implementation.
when are big integers useful?
- they’re used in cryptography (e.g. for large key sizes)
- for math on really big integers
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!