Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Spock Newsgroups: comp.lang.java.programmer Subject: Re: Java puzzler Date: Sat, 14 May 2011 19:33:45 -0400 Organization: Starfleet Lines: 15 Message-ID: References: <4db69c13-878f-4806-adb2-a3c5adb1c48c@glegroupsg2000goo.googlegroups.com> <-8mdnSRPEIdA21HQnZ2dnUVZ_j2dnZ2d@earthlink.com> NNTP-Posting-Host: Ak7xW7rxcb3Y6UXwoZfR1w.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Forte Agent 2.0/32.652 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4089 On 14/05/2011 11:46 AM, markspace wrote: > If you've ever actually tried to use BigDecimal with its "infinite > precision" mode, you know that this blows up pretty quickly due to out > of memory errors. The first time you try to evaluate 1/3, it throws an > error. Infinite precision is not the answer. This erroneously presupposes that the only means available for representing fractions is as binary or decimal floating-point or fixed-point. Many other programming languages have a Ratio or Rational type, including most Lisps and all Smalltalks; a Java equivalent would represent 1/3 exactly as a BigInteger numerator 1 and a BigInteger denominator 3. Of course, irrational numbers like sqrt(2) and pi would still present difficulties.