# Very odd thing with float numbers in Python

**URL:** <https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300>\
**Category:** Factual Questions\
**Created:** [March 20, 2021, 2:57pm UTC](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300 "2021-03-20T14:57:13Z")\
**Posts on this page:** 4\
**Page:** 3

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [April 5, 2021, 11:06pm UTC](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300/41 "2021-04-05T23:06:44Z")

</div>

> [@am77494](#):
>
> n Indian numbering system; 1,00,000 is lakhs and 1,00,00,000 is crores. This system has been used since ancient times and it has nothing to do with " too small for handling large financial transactions"

I’m sorry about misspelling the currency of India. Lakhs and crores were not the resolution we were required to use for stock market reports: we used 1000 or 10,000 (I don’t remember which), and we did so because the stock market did so.

---

<div class="post-metadata">

**Author:** ![Francis\_Vaughan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/francis_vaughan/32/3093_2.png) [@Francis\_Vaughan](https://boards.straightdope.com/u/Francis_Vaughan)\
**Post date:** [April 6, 2021, 2:01am UTC](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300/42 "2021-04-06T02:01:27Z")

</div>

> [@Precambrianmollusc](#):
>
> Ariane 5 rocket oopsie that involved a conversion from a 64bit float to a 16bit signed integer which led to an overflow

We used to use this as one of the motivating examples in teaching software engineering. I found a video of the launch to kick off the lecture. The flaw is much deeper than just a numerical overflow. The the Swiss cheese model of failure was very deep. One could (and I did) spend a large fraction of a lecture unwinding how they got there and what the real failures were.

---

<div class="post-metadata">

**Author:** ![Precambrianmollusc](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/precambrianmollusc/32/63_2.png) [@Precambrianmollusc](https://boards.straightdope.com/u/Precambrianmollusc)\
**Post date:** [April 6, 2021, 2:06am UTC](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300/43 "2021-04-06T02:06:44Z")

</div>

Agree the root cause wasn’t the fp error but it’s a good lead into an interesting cluster. The report and the article gets deep into the root causes, I am making one slide on this for the next ‘safety moment’ I have to give prior to a client presentation, some really good lessons and fortunately the only loss was a bucket load of cash.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [April 6, 2021, 2:48am UTC](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300/44 "2021-04-06T02:48:10Z")

</div>

> [@Schnitte](#):
>
> Along the lines of what caused this infamous Intel Pentium bug in the 1990s?

You didn’t really get an answer for this one. As noted, you’ve discovered the inevitable problems with representing a decimal fraction with a binary fraction. Not a bug–working as designed. The Intel FDIV bug was in fact a genuine bug, caused by errors in a lookup table for their division algorithm. You would give it two numbers, and expecting a certain result based on rounding rules and the like–and didn’t get that result for some input numbers.

[Previous page](https://boards.straightdope.com/t/very-odd-thing-with-float-numbers-in-python/938300.md?page=2)
