Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

javascript > math.js

0.3 - 0.2 // 0.09999999999999998
math.number(math.subtract(math.bignumber(0.3), math.bignumber(0.2))) // 0.1
https://snipt.net/embed/259948083580ef7fb062b1ad75aba2fe/
https://snipt.net/raw/259948083580ef7fb062b1ad75aba2fe/
259948083580ef7fb062b1ad75aba2fe
text
Text only
4
2016-12-09T23:20:28
True
False
False
Feb 21, 2016 at 11:53 PM
/api/public/snipt/144381/
javascript-mathjs
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>0.3 - 0.2 // 0.09999999999999998 </span><span id="L-2"><a name="L-2"></a>math.number(math.subtract(math.bignumber(0.3), math.bignumber(0.2))) // 0.1 </span></pre></div> </td></tr></table>
float, javascript, math

Text only

elixir decimal

1
2
3
4
5
6
0.3 - 0.1 # 0.19999999999999998
alias Decimal, as: D
D.sub(D.new(0.3), D.new(0.1)) # #Decimal<0.2>
D.sub(D.new(0.3), D.new(0.1)) |> D.to_string # "0.2"
{n, _} = D.sub(D.new(0.3), D.new(0.1)) |> D.to_string |> Float.parse # {0.2, ""}
n == 0.2 # true
https://snipt.net/embed/1637a2df443a7138ab88d0b3b18886f6/
https://snipt.net/raw/1637a2df443a7138ab88d0b3b18886f6/
1637a2df443a7138ab88d0b3b18886f6
text
Text only
7
2016-12-09T23:20:36
True
False
False
/api/public/snipt/144380/
elixir-decimal
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>0.3 - 0.1 # 0.19999999999999998 </span><span id="L-2"><a name="L-2"></a>alias Decimal, as: D </span><span id="L-3"><a name="L-3"></a>D.sub(D.new(0.3), D.new(0.1)) # #Decimal&lt;0.2&gt; </span><span id="L-4"><a name="L-4"></a>D.sub(D.new(0.3), D.new(0.1)) |&gt; D.to_string # &quot;0.2&quot; </span><span id="L-5"><a name="L-5"></a>{n, _} = D.sub(D.new(0.3), D.new(0.1)) |&gt; D.to_string |&gt; Float.parse # {0.2, &quot;&quot;} </span><span id="L-6"><a name="L-6"></a>n == 0.2 # true </span></pre></div> </td></tr></table>
decimal, elixir, float, math
Copyrighted, illegal, or inappropriate content? Email [email protected].