Skip to Content

A stick figure smiling

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!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
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!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)