Hi,
Le 5/17/21 à 11:37 AM, Tung Anh Nguyen a écrit :
> I'm using Python 3.8.5 on Ubuntu 20.04. I just don't understand these
> things?
>
> >>> float("8.1")*100
> 810.0
> >>> float("8.2")*100
> 819.9999999999999 ?
> >>> float("8.3")*100
> 830.0000000000001 ?
> >>> float("8.4")*100
> 840.0
>
> Why is that? Is that a bug? or something I don't know yet? Could you
> guys answer my question?
We can answer, there's a whole page on the subject on docs.python.org:
=> https://docs.python.org/3/tutorial/floatingpoint.html
and if you want a bit of amusement around this:
>>> import webbrowser
>>> webbrowser.open(f"https://{.1+.2}.com")
Bests,
--
[Julien Palard](https://mdk.fr)