<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Or a bit faster ?<div><br></div><div>Scale everything by a factor of 100 (or what ever suits the problem) and use fix point calculations.</div><div><br></div><div>245245 * 10000 = 2452450000</div><div><br></div><div>We just need to eat or drink something that make us see the dots. :-)</div><div><br></div><div>/Tony</div><div><br></div><div><br><div><div>On 27 nov 2013, at 06:52, I-T <<a href="mailto:iqbaltalaat@gmail.com">iqbaltalaat@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">You might want to try:-<div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><a href="https://github.com/tim/erlang-decimal">https://github.com/tim/erlang-decimal</a><br>
</div><div><br></div></blockquote>Run</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>Iqbal-Bhatti:ebin afrobeard$ erl</div><div>Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false]</div>
<div><br></div><div>Eshell V5.7.4 (abort with ^G)</div><div>1> decimal:multiply("2452.45", "100").</div><div>{0,24524500,-2}</div><div>2> </div></div><div><br></div></blockquote>Best Regards,</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 27 November 2013 09:35, Michael Turner <span dir="ltr"><<a href="mailto:michael.eugene.turner@gmail.com" target="_blank">michael.eugene.turner@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Gee, now might be a good time to bore everyone with a war story: a<br>
startup I once worked for independently /pre/-invented the Pentium<br>
Floating Point Bug, against my strenuous protests. How could this<br>
happen, I wondered, as I was losing the battle for IEEE-standard<br>
purity? Maybe, I thought, it's because we're a small company that<br>
can't afford to hire experts to ratify my opinion?<br>
<br>
We were using Weitek FPU adder and multiplier chips in our hardware,<br>
and I implemented floating point division the way they said to do it -<br>
the right way. Tried to, that is. I got overruled.<br>
<br>
Not too many years later, for the Pentium design, Intel acquired<br>
Weitek's IP. Then they introduced very similar mistakes in floating<br>
point arithmetic, through no fault of Weitek. Ours, at least, could<br>
have been patched by sending customers a new ROM to socket. Intel's<br>
errors went onto a single chip.<br>
<br>
What I learned about IEEE floating point arithmetic is that if you try<br>
to clean up floating point "errors" one way, you just squeeze the<br>
errors out some place else.<br>
<br>
What I learned about people is that Size Doesn't Matter.<br>
<br>
The proximate provocation in both cases: somebody didn't like how the<br>
number printed. I first saw "errors" like when I was in high school,<br>
programming in Dartmouth BASIC. I was told, "floating point is like<br>
that - if it weren't that, it would be something worse." So I was<br>
prepared. But lots of people now graduate with C.S. degrees who aren't<br>
prepared.<br>
<br>
<br>
Regards,<br>
Michael Turner<br>
Executive Director<br>
Project Persephone<br>
K-1 bldg 3F<br>
7-2-6 Nishishinjuku<br>
Shinjuku-ku Tokyo 160-0023<br>
Tel: <a href="tel:%2B81%20%283%29%206890-1140" value="+81368901140">+81 (3) 6890-1140</a><br>
Fax: <a href="tel:%2B81%20%283%29%206890-1158" value="+81368901158">+81 (3) 6890-1158</a><br>
Mobile: <a href="tel:%2B81%20%2890%29%205203-8682" value="+819052038682">+81 (90) 5203-8682</a><br>
<a href="mailto:turner@projectpersephone.org">turner@projectpersephone.org</a><br>
<a href="http://www.projectpersephone.org/" target="_blank">http://www.projectpersephone.org/</a><br>
<br>
"Love does not consist in gazing at each other, but in looking outward<br>
together in the same direction." -- Antoine de Saint-Exupéry<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Wed, Nov 27, 2013 at 12:28 PM, Richard A. O'Keefe <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:<br>
><br>
> On 27/11/2013, at 3:01 PM, Sanath Prasanna wrote:<br>
><br>
>> I accepted your comment. But generally we expected full value. I did same in another scripting language like php. It is given correct result.<br>
><br>
> Wrong. It *calculated* the same number as Erlang did,<br>
> but then it *displayed* a different number, a rounded version.<br>
><br>
> m% cat >foo.php<br>
> <?php<br>
> $a = 2452.45*100;<br>
> echo $a; echo "\n";<br>
> $a = $a - 245245.0;<br>
> echo $a; echo "\n";<br>
> exit;<br>
> ?><br>
> <EOF><br>
> m% php foo.php<br>
> 245245<br>
> -2.9103830456734E-11<br>
><br>
> We see from this that while the number *displays as*<br>
> 245245, it is not *equal to* 245245.<br>
><br>
> As I said, PHP computed *exactly* the same answer as Erlang.<br>
> Who is this "we" who "expect full value"?<br>
> This is floating-point arithmetic, not rational arithmetic.<br>
><br>
> (Our 2nd year students are taught this stuff, but it doesn't<br>
> really take. In 3rd year they have an exercise they have to<br>
> do where they start to really understand that floating point<br>
> arithmetic is *not* arithmetic on the mathematical real<br>
> numbers, but a different mathematical system which sort of<br>
> approximates the algebra of the reals. They learn that<br>
> adding up an array of numbers from left to right generally<br>
> gives you a different answer from adding up from right to<br>
> left, for example.)<br>
><br>
> Numbers in IEEE floating point arithmetic are precise,<br>
> but are bounded in their precision, and arithmetic operations<br>
> on them (including conversion between decimal and binary)<br>
> have to round their answers to something that is representable.<br>
> There's a rounding in the conversion of 2452.45 to binary,<br>
> and then the multiplication incurs another rounding.<br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Iqbal Talaat Bhatti</div><div class="gmail_extra"><br><span>"If we did all the things we are capable of doing, we would
literally astound ourselves." - Thomas Edison</span><br>
</div></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">"Installing applications can lead to corruption over time. </span><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; "><br></span></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>