From 20f810a1c28bc6528e76f4542db2b70ff61aae88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sun, 30 Oct 2022 10:59:53 -0300 Subject: [PATCH] =?UTF-8?q?Imprecis=C3=A3o=20dos=20n=C3=BAmeros=20de=20pon?= =?UTF-8?q?to=20flutuante=20+=20round=20e=20decimal.Decimal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula55.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 aula55.py diff --git a/aula55.py b/aula55.py new file mode 100644 index 0000000..a879546 --- /dev/null +++ b/aula55.py @@ -0,0 +1,14 @@ +""" +Imprecisão de ponto flutuante +Double-precision floating-point format IEEE 754 +https://en.wikipedia.org/wiki/Double-precision_floating-point_format +https://docs.python.org/pt-br/3/tutorial/floatingpoint.html +""" +import decimal + +numero_1 = decimal.Decimal('0.1') +numero_2 = decimal.Decimal('0.7') +numero_3 = numero_1 + numero_2 +print(numero_3) +print(f'{numero_3:.2f}') +print(round(numero_3, 2))