Skip to Content
Navigation:

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!

science <3 floating point

floating point was invented to do scientific computation

  • weather simulations!
  • earthquake modeling!
  • orbital mechanics!

scientists don’t need unlimited precision…

we only know an electron’s mass to 9 decimal places anyway…

9 decimal places is already VERY precise!

but they do need TINY numbers and GIANT numbers

mass of hydrogen atom:

1.6735575 * 10^-24 grams

distance to Andromeda galaxy:

2.4 * 10^22 meters

floating point is inspired by scientific notation

1.6735575 x 10^-24

The idea in floating point is to store a number by splitting it into:

  • the exponent (like -24)
  • the multiplier (like 1.6735575)
  • and its sign (+ or -)

floating point isn’t just used for science though

For example, Javascript’s number type is floating point. Before it added BigInt in 2021, Javascript didn’t have integers at all!

Similarly, numbers in JSON are often interpreted as floating point numbers.

panel:

people usually explain floating point as “it’s scientific notation, but in binary!” That’s true, but I’ve never found it intuitive so we’re going to explain it a different way.

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)