<story><title>Perl 6 hands-on tutorial – A small introduction to a big language [pdf]</title><url>http://jnthn.net/papers/2015-spw-perl6-course.pdf</url></story><parent_chain><item><author>chubot</author><text>Why is this surprising?  Floats are defined by the hardware essentially, not the language.&lt;p&gt;And this is how they work: they&amp;#x27;re binary, not decimal.  Computers are binary, not decimal.  0.1 can&amp;#x27;t be represented exactly as binary.&lt;p&gt;Python has a decimal type, if that&amp;#x27;s what you want: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.python.org&amp;#x2F;2&amp;#x2F;library&amp;#x2F;decimal.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.python.org&amp;#x2F;2&amp;#x2F;library&amp;#x2F;decimal.html&lt;/a&gt;&lt;p&gt;I consider it a basic point of computer literacy to understand this.</text></item><item><author>natch</author><text>&amp;quot;Try 0.1 + 0.2 == 0.3 in some other language, then try it in Perl 6.&amp;quot;&lt;p&gt;Whoa, wtf python:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    $ python
    Python 3.4.3 (default, Jul 13 2015, 12:18:23) 
    [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
    Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
    &amp;gt;&amp;gt;&amp;gt; 0.1 + 0.2 == 0.3
    False
    &amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;</text></item></parent_chain><comment><author>dragonwriter</author><text>That decimal literals represent binary floating point numbers is defined by the language, not the hardware.&lt;p&gt;I consider it a basic point of language design literacy that exact decimal literals without some other indicators should not represent an inexact type that isn&amp;#x27;t designed to represent decimal data.&lt;p&gt;Infuriatingly, very few languages get that right. But perl 6 isn&amp;#x27;t unique in doing so; Scheme had been doing it right for decades.</text></comment>
<story><title>Perl 6 hands-on tutorial – A small introduction to a big language [pdf]</title><url>http://jnthn.net/papers/2015-spw-perl6-course.pdf</url></story><parent_chain><item><author>chubot</author><text>Why is this surprising?  Floats are defined by the hardware essentially, not the language.&lt;p&gt;And this is how they work: they&amp;#x27;re binary, not decimal.  Computers are binary, not decimal.  0.1 can&amp;#x27;t be represented exactly as binary.&lt;p&gt;Python has a decimal type, if that&amp;#x27;s what you want: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.python.org&amp;#x2F;2&amp;#x2F;library&amp;#x2F;decimal.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.python.org&amp;#x2F;2&amp;#x2F;library&amp;#x2F;decimal.html&lt;/a&gt;&lt;p&gt;I consider it a basic point of computer literacy to understand this.</text></item><item><author>natch</author><text>&amp;quot;Try 0.1 + 0.2 == 0.3 in some other language, then try it in Perl 6.&amp;quot;&lt;p&gt;Whoa, wtf python:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    $ python
    Python 3.4.3 (default, Jul 13 2015, 12:18:23) 
    [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
    Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
    &amp;gt;&amp;gt;&amp;gt; 0.1 + 0.2 == 0.3
    False
    &amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;</text></item></parent_chain><comment><author>kbenson</author><text>While defaulting to floats for rational numbers may be the default for many languages, it is by no means the only way to store them, which is why we&amp;#x27;re talking about them.  In Perl 6 they are often stored as a numerator and denominator within the Rat type, and converted for display.</text></comment>