David Wolever - Floats are Friends: making the most of IEEE754.00000000000000002 - PyCon 2019

"Speaker: David Wolever
Floating point numbers have been given a bad rap. They're mocked, maligned, and feared; the but of every joke, the scapegoat for every rounding error.
But this stigma is not deserved. Floats are friends! Friends that have been stuck between a rock and a computationally hard place, and been forced to make some compromises along the way… but friends never the less!
In this talk we'll look at the compromises that were made while designing the floating point standard (IEEE754), how to work within those compromises to make sure that `0.1 + 0.2 = 0.3` and not `0.30000000000000004`, how and when floats can and cannot be safely used, and some interesting history around fixed point number representation.
This talk is ideal for anyone who understands (at least in principle) binary numbers, anyone who has been frustrated by `nan` or the fact that `0.3 == 0.1 + 0.2 = False`, and anyone who wants to be the life of their next party.
This talk will not cover more complicated numerical methods for, ex, ensuring that algorithms are floating-point safe. Also, if you're already familiar with the significance of ""52"" and the term ""mantissa"", this talk might be more entertaining than it will be educational for you.
Slides can be found at: speakerdeck.com/pycon2019 and github.com/PyCon/2019-slides"

Пікірлер: 4

  • @reginaldcrapo132
    @reginaldcrapo1325 жыл бұрын

    Great talk, David.

  • @LambdaJack
    @LambdaJack5 жыл бұрын

    It's over... 9000!!

  • @rodamira
    @rodamira4 жыл бұрын

    Instead of using Decimal (or floats) when dealing with money, you might want to consider using something like micro units, represented as ints (see Google's DFP API). That is, one "dollar" is not 1.00, but rather, it's represented as 1000000. Ten cents would be 1000000 / 10. You get the idea. No loss of precision is likely to occur, and performance is as good as it gets.

  • @SVVV97
    @SVVV975 жыл бұрын

    Interesting - they should've not allowed the Python 2 usage though :D

Келесі