<story><title>How to Handle Monetary Values in JavaScript</title><url>https://frontstuff.io/how-to-handle-monetary-values-in-javascript</url></story><parent_chain><item><author>b2ccb2</author><text>I really like the approach Perl 6 takes with FatRat[1]. You basically have an object which holds a numerator and denominator, so all arithmetic calculations do not loose precision.&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.perl6.org&amp;#x2F;type&amp;#x2F;FatRat&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.perl6.org&amp;#x2F;type&amp;#x2F;FatRat&lt;/a&gt;</text></item></parent_chain><comment><author>tikhonj</author><text>Rational numbers don&amp;#x27;t lose precision, but the compromise is that they can get arbitrarily large after a series of calculations, even if the calculations themselves involve small numbers.&lt;p&gt;Having &lt;i&gt;access&lt;/i&gt; to rational numbers is great and there are times they are incredibly useful, but I don&amp;#x27;t think it&amp;#x27;s a good &lt;i&gt;default&lt;/i&gt;.</text></comment>
<story><title>How to Handle Monetary Values in JavaScript</title><url>https://frontstuff.io/how-to-handle-monetary-values-in-javascript</url></story><parent_chain><item><author>b2ccb2</author><text>I really like the approach Perl 6 takes with FatRat[1]. You basically have an object which holds a numerator and denominator, so all arithmetic calculations do not loose precision.&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.perl6.org&amp;#x2F;type&amp;#x2F;FatRat&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.perl6.org&amp;#x2F;type&amp;#x2F;FatRat&lt;/a&gt;</text></item></parent_chain><comment><author>christophilus</author><text>Clojure does this out of the box: `(&amp;#x2F; 1 3)` is 1&amp;#x2F;3. Removes a lot of annoying floating point errors.</text></comment>