# Why is "floating point" (a computing term) called floating point?

**URL:** <https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214>\
**Category:** Factual Questions\
**Created:** [May 11, 2014, 10:42pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214 "2014-05-11T22:42:18Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Blakeyrat](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blakeyrat](https://boards.straightdope.com/u/Blakeyrat)\
**Post date:** [May 14, 2014, 4:54pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/21 "2014-05-14T16:54:16Z")

</div>

To go “outside the box” and answer the question from another perspective…

Because the standard that specifies this type of binary number (IEEE 754) calls it “floating point”. Regardless of whatever reason the standard had for choosing that name, once it’s in the standard, it’s gospel.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [May 14, 2014, 6:33pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/22 "2014-05-14T18:33:18Z")

</div>

> [@Blakeyrat](#):
>
> once it’s in the standard, it’s gospel.

And we all know how religious people are at obeying every single one of the gospels at all times.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 14, 2014, 6:57pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/23 "2014-05-14T18:57:05Z")

</div>

> [@](#):
>
> Quoth **Learjeff** :
> 
> A similar kind of problem also happens using floating point, too. For example, in some digital audio applications, the mathematician can write out matrix equations that solve a problem (implement a filter, for example). The math can be relatively elegant and produce ideal results, in theory, but when implemented in a straightforward way, the results don’t match. The reason is that the analytic equations might rely on an intermediate term with two near-infinites or near-infinitesimals that divide to produce a number in the normal range. If you don’t have enough bits of precision, it goes south very quickly.
> 
> The good news is that floating point (especially double-precision, which is the default for things like C function parameters) pushes most of those cases into applications where fairly serious math is involved, and don’t usually bite us math-challenged folks in the ass too often. Scientists may not be so lucky.

Indeed, I’ve encountered this problem in scientific coding. The quick-and-dirty solution is to store the logs of the variables instead of the variables themselves (and if the logs of your variables are growing out of control, forget it, it’s hopeless). But then you need to work out a way to add such variables together, which is a royal pain. The real solution is to look at your actual equations and do math yourself, instead of relying on the computer, to convert them into a form that does not have the indeterminate forms in it.

---

<div class="post-metadata">

**Author:** ![Leo\_Bloom](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/leo_bloom/32/10377_2.png) [@Leo\_Bloom](https://boards.straightdope.com/u/Leo_Bloom)\
**Post date:** [May 14, 2014, 7:06pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/24 "2014-05-14T19:06:32Z")

</div>

> [@Chronos](#):
>
> …And the reason that you seldom see mention of fixed point numbers is because they’re really just integers with different units. For instance, one might have a number in a computer representing weight in pounds, measured to a precision of 1/16 pound… But that’s just the same thing as weight measured in integer ounces. And if there isn’t a pre-existing unit that corresponds to the precision you want, then you just invent one.

Beautiful reframing/approach to understanding the concept.  
ETA: the other posts are cool too…

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 14, 2014, 7:40pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/25 "2014-05-14T19:40:21Z")

</div>

Note that fixed point numbers have certain problems. A notable one is the multiply-before-divide problem.

92.1 / 100.1 \* 100.1 = 0.0

When represented as integers

921/1001 \* 1001 = 0

This is because 921/1001 = 0, since integer arithmetic will always floor (round down) a result. To get the correct answer you need (92.1\*100.1)/100.1.

The safer option for this sort of thing is a rational type, where you represent it as

(921 / 10) / (1001/10) \* (1001/10) = 921 / 10

However, this is slower and takes up the size of two integers (numerator and denominator), even if it is safer.

Edit: Not that floating point numbers don’t have problems. They have many, many, many, many problems.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [May 14, 2014, 10:23pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/26 "2014-05-14T22:23:40Z")

</div>

> [@Learjeff](#):
>
> Well, it turns out you get to choose between nice tight semantics that produce truly bizarre-looking results from seemingly ordinary math, or looser semantics that usually produce “sensible” results but have bizarre corner cases. What we often don’t realize when we write a math expression is how much we might be demanding of intermediate storage for temporary results.
> 
> A similar kind of problem also happens using floating point, too. For example, in some digital audio applications, the mathematician can write out matrix equations that solve a problem (implement a filter, for example). The math can be relatively elegant and produce ideal results, in theory, but when implemented in a straightforward way, the results don’t match. The reason is that the analytic equations might rely on an intermediate term with two near-infinites or near-infinitesimals that divide to produce a number in the normal range. If you don’t have enough bits of precision, it goes south very quickly.

This is why a serious programmer, who expects to be doing mathematical programming, needs to take a class in numerical analysis. Is that still required of Computer Science majors these days? That is a full-semester class in doing heavy-duty computational mathematics, where you study how to do exactly this sort of stuff.

Note that you can’t solve all problems simply by using double-precision floats instead of single-precision, or by using quadruple-precision instead of double-precision. If the problem is that you need 18 significant digits instead of only 8 to compute the trajectory to get your rocket ship to Jupiter, then using greater precision may be the solution. If you’re computing sums of infinite series by adding up successive terms until you’ve got the precision you need, that often won’t work. You’ll end up with your 18 or whatever “significant” digits, but they will be random gibberish.

There is also the problem of using computed values in comparisons. Suppose you’ve added a bunch of floats, and you want to see if the result is \< 10.0 thus:  
if ( sum \< 10.0 ) . . .  
It’s entirely possible the sum _should be_ exactly 10.0 but will fall a little below that due to rounding error, and no amount of additional precision will solve it, and the branch will go the wrong way. This is a very common problem in uncarefully-written financial software, where accuracy down to the exact penny is required. (I’ve spent, and still spend, a lot of time working with a financial application that is full of bugs like this.)

Recommended reading: We discussed that in some detail a while back, in [this thread](http://boards.straightdope.com/sdmb/showthread.php?t=640830), from February 2012, starting in post #4.

For additional introductory reading, also check out [this thread](http://boards.straightdope.com/sdmb/showthread.php?t=654340), from June 2012. There is a lot of discussion there about what constitutes good programming practices.

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [May 14, 2014, 11:11pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/27 "2014-05-14T23:11:00Z")

</div>

> [@Jragon](#):
>
> Note that fixed point numbers have certain problems. A notable one is the multiply-before-divide problem.
> 
> 92.1 / 100.1 \* 100.1 = 0.0
> 
> When represented as integers
> 
> 921/1001 \* 1001 = 0
> 
> This is because 921/1001 = 0, since integer arithmetic will always floor (round down) a result. […]

This is a problem with how you’re doing the division, nothing to do with the following multiply. Your answer for just the division 92.1/100.1 should be 0.9.

Then you’d end up with 92.1 / 100.1 \* 100.1 = 90.0 or 90.1. Not quite as egregious.

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 14, 2014, 11:16pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/28 "2014-05-14T23:16:48Z")

</div>

> [@ZenBeam](#):
>
> This is a problem with how you’re doing the division, nothing to do with the following multiply. Your answer for just the division 92.1/100.1 should be 0.9.
> 
> Then you’d end up with 92.1 / 100.1 \* 100.1 = 90.0 or 90.1. Not quite as egregious.

Well, yes, but the point is that most fixed-point arithmetic uses scaled ints, and you don’t really have a choice to do division differently if you use scaled ints since you’re a slave to how the ALU does it.

li $t0, 921 # t0 = 921  
li $t1, 1001 # t1 = 1001  
div $t0, $t1 # stores result of t0/t1 in lo  
mflo $v0 # get result of division

(Or the equivalent in your favorite assembler) is always going to result in the value in $v0 being 0. Hence you multiply before you divide because otherwise for any a/b, if a\<b; a/b=0. [Even 999/1000 == 0](http://play.golang.org/p/ji2htTDzpb). If you don’t you lose all scaling precision between two integers.

---

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [May 14, 2014, 11:31pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/29 "2014-05-14T23:31:31Z")

</div>

(IMHO) a bigger issue is overflow.

If I have 16 bits, and I want to be able to store a number with precision to one part in a thousand (.001), I need to dedicate 10 bits to the decimal part, leaving only 6 bits for the integer part. This means I can only store numbers from 0.000 - 63.999 (or half that range for positive and negative numbers). This is a big problem with microcontroller code, where memory is tight, and word size is small. If you don’t pick your fixed point representation correctly at the outset, you may find that something simple (like multiplying by a scale factor) will cause the result to exceed the 16 bits available.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 14, 2014, 11:32pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/30 "2014-05-14T23:32:44Z")

</div>

Or alternately, you choose appropriate numbers of digits for the various quantities you’re working with, such that anything you’re dividing will always come out with reasonable precision. Which admittedly might not always be possible, but sometimes it will be.

And I can’t speak for computer scientists, but I was required to take a numerical course as a physicist. We didn’t cover fixed point much, though: Most of what I know about the practicalities of that, I learned from video game theorycrafting (fixed point operations used to be really popular in video games, because a little lost precision isn’t usually a big deal in a game, but speed is).

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [May 14, 2014, 11:51pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/31 "2014-05-14T23:51:25Z")

</div>

> [@Jragon](#):
>
> Well, yes, but the point is that most fixed-point arithmetic uses scaled ints, and you don’t really have a choice to do division differently if you use scaled ints since you’re a slave to how the ALU does it.
> 
> li $t0, 921 # t0 = 921  
> li $t1, 1001 # t1 = 1001  
> div $t0, $t1 # stores result of t0/t1 in lo  
> mflo $v0 # get result of division
> 
> (Or the equivalent in your favorite assembler) is always going to result in the value in $v0 being 0. Hence you multiply before you divide because otherwise for any a/b, if a\<b; a/b=0. [Even 999/1000 == 0](http://play.golang.org/p/ji2htTDzpb). If you don’t you lose all scaling precision between two integers.

When you calculate A/B, _somewhere_ you need to multiply by 10. If I have A = 100.1 and B = 92.1, and I do the integer division, I get 1001/921 = 1. But the integer 1 doesn’t represent 1.0, it represents 0.1. You need to multiply by 10 to get the integer that represents 1.0.

So when you’re calculating 92.1/100.0, you can do that multiply-by-10 first instead of last, giving you (921 \* 10) / 1001 = 9 (which represents 0.9).

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [May 15, 2014, 3:39pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/32 "2014-05-15T15:39:37Z")

</div>

> [@Senegoid](#):
>
> This is why a serious programmer, who expects to be doing mathematical programming, needs to take a class in numerical analysis. Is that still required of Computer Science majors these days? That is a full-semester class in doing heavy-duty computational mathematics, where you study how to do exactly this sort of stuff.

Yeah, no kidding. I wish I had, but I don’t remember it being recommended for computer engineering students back in the 70’s.

Another one programmers routinely get wrong is probability. Most of the time, we don’t need to know probability, but every now and then a serious probability problem comes up, and I usually chuckle inside at their confidence in their answers, remembering how easy it was to get it wrong in the one prob/stat course I did take way back when. IMHO, a big company should have a small applied math department available when needed for these kinds of questions. Or perhaps an applied mathematician on retainer, a prof at a nearby university. Oh well!

I’m delighted that I can get the Monty Python problem correct. When it gets much more complicated than that (just about anytime I can’t enumerate all the cases), I lose confidence pretty fast.

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [May 15, 2014, 3:48pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/33 "2014-05-15T15:48:28Z")

</div>

> [@Learjeff](#):
>
> I’m delighted that I can get the Monty Python problem correct.

Well, except maybe the name…

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 15, 2014, 3:55pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/34 "2014-05-15T15:55:58Z")

</div>

OK, I’m lost. What is the Monty Python problem? I’m guessing it’s some reference to “Three is the number to which thou shalt count”, but I can’t see how to make that relevant to programming.

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [May 15, 2014, 4:47pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/35 "2014-05-15T16:47:08Z")

</div>

I’m guessing he meant Monty Hall.

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [May 15, 2014, 5:40pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/36 "2014-05-15T17:40:23Z")

</div>

> [@ZenBeam](#):
>
> Well, except maybe the name…

ROFL.

Yeah, I meant Monte Hall.

Thank goodness for code reviews.

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [May 15, 2014, 5:46pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/37 "2014-05-15T17:46:01Z")

</div>

> [@Chronos](#):
>
> OK, I’m lost. What is the Monty Python problem? I’m guessing it’s some reference to “Three is the number to which thou shalt count”, but I can’t see how to make that relevant to programming.

That’s a lot more amusing than what I was thinking!

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [May 15, 2014, 8:28pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/38 "2014-05-15T20:28:33Z")

</div>

> [@Learjeff](#):
>
> ROFL.
> 
> Yeah, I meant Monte Hall.
> 
> Thank goodness for code reviews.

And then there was the Quantum Hall Problem, where there were three uncollapsed wavefunctions … OK, OK, I’ll stop.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [May 16, 2014, 3:02am UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/39 "2014-05-16T03:02:00Z")

</div>

Apparently, the Monty Hall problem is the Monty Python problem now. 🙂

Googling it, one finds numerous discussions of analyses (simulations?) of the Monty Hall problem, done in Python.

[Example.](https://coderwall.com/p/fezbpa)

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [May 16, 2014, 8:48pm UTC](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214/40 "2014-05-16T20:48:59Z")

</div>

> [@Senegoid](#):
>
> Apparently, the Monty Hall problem is the Monty Python problem now. 🙂
> 
> Googling it, one finds numerous discussions of analyses (simulations?) of the Monty Hall problem, done in Python.
> 
> [Example.](https://coderwall.com/p/fezbpa)

lol

Python is my scripting language of choice, despite it’s faults.

[Previous page](https://boards.straightdope.com/t/why-is-floating-point-a-computing-term-called-floating-point/688214.md?page=1)
