<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Dinheiro on Python Brasil — Aprenda Python em Português</title>
    <link>https://python.dev.br/tags/dinheiro/</link>
    <description>Recent content in Dinheiro on Python Brasil — Aprenda Python em Português</description>
    <generator>Hugo</generator>
    <language>pt-br</language>
    <lastBuildDate>Mon, 27 Jul 2026 01:14:21 +0000</lastBuildDate>
    <atom:link href="https://python.dev.br/tags/dinheiro/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Decimal em Python: dinheiro, centavos e cálculos precisos</title>
      <link>https://python.dev.br/blog/python-decimal-dinheiro-calculos-precisos/</link>
      <pubDate>Mon, 27 Jul 2026 00:00:00 +0000</pubDate>
      <guid>https://python.dev.br/blog/python-decimal-dinheiro-calculos-precisos/</guid>
      <description>&lt;p&gt;O módulo &lt;code&gt;decimal&lt;/code&gt; é a escolha mais segura da biblioteca padrão para representar &lt;strong&gt;dinheiro, centavos, taxas e quantidades decimais em Python&lt;/strong&gt;. Ele evita os resíduos de precisão comuns do tipo &lt;code&gt;float&lt;/code&gt;, permite escolher a regra de arredondamento e ajuda a tornar cálculos de preços, descontos, comissões e totais reproduzíveis.&lt;/p&gt;&#xA;&lt;p&gt;A recomendação direta é: crie valores com &lt;code&gt;Decimal(&amp;quot;19.90&amp;quot;)&lt;/code&gt;, nunca com &lt;code&gt;Decimal(19.90)&lt;/code&gt;; arredonde no ponto definido pela regra do negócio usando &lt;code&gt;quantize(Decimal(&amp;quot;0.01&amp;quot;))&lt;/code&gt;; e não misture &lt;code&gt;Decimal&lt;/code&gt; com &lt;code&gt;float&lt;/code&gt;. Para sistemas simples que trabalham exclusivamente com centavos, &lt;code&gt;int&lt;/code&gt; também é uma boa opção.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
