From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,890e7bb13b3c2a7f,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.197.201 with SMTP id iw9mr361403pbc.6.1350637039303; Fri, 19 Oct 2012 01:57:19 -0700 (PDT) Received: by 10.68.233.130 with SMTP id tw2mr175814pbc.12.1350637039284; Fri, 19 Oct 2012 01:57:19 -0700 (PDT) Path: s9ni23372pbb.0!nntp.google.com!kr7no4559106pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Oct 2012 01:57:19 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.117.199.50; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 97.117.199.50 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <29fc1667-46f8-40b5-aef9-bea87dc862b4@googlegroups.com> Subject: How to get high-precision floating point--MPFR From: Jerry Injection-Date: Fri, 19 Oct 2012 08:57:19 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-10-19T01:57:19-07:00 List-Id: I have a few lines of floating point code in a large program which I suspec= t could be causing subtle errors. (It uses lots of recursion with some dice= y numbers.) I am using GNAT GPL 2011 on an Intel Mac, Long_Float (64 bits) = everywhere. I understand that recent versions of GCC come with MPFR (Multiple Precision= Floating-Point Reliably). Here is what I want to do type Giant_Float is digits 30; but GNAT says, sorry not more than digits 18 (see below related note). So w= hat I think I have to do is find an Ada binding to MPFR and re-write my cod= e. Is that correct? Do I already have the library with GPL 2011 or OS X 10.= 7? If not, I can build with Macports. I gather that Vincent's binding here http://code.google.com/p/adabindinggmpmpfr/ is the way to go. Did this binding ever make it into GCC? If I do quadruple precision I would expect the relevant lines to execute 5-= 6 times slower than with Long_Float. I need only multiplication and additio= n, and will convert the result to Long_Float. I don't need a computational model where the precision increases every time= I do an operation; I'm certain that I can easily specify a fixed precision= that will suffice. Is that the way MPFR works? On a related note, I have a (borrowed/stolen) program which prints out some= numeric attributes. I won't bother pasting the code, but a partial output = listing is this: Long_Float bits is 64 Long_Long_Float bits is 128 The smallest Long_Float is 1.94469227433160678E-62 The largest Long_Float is 2.57110087081438330E+61 The number of digits in Long_Float is 15 The size of the Long_Float mantissa in bits is 51 However, the CPU's Long_Float mantissa is 53 The smallest Long_Long_Float is 1.76868732008334226E-74 The largest Long_Long_Float is 2.82695530364541493E+73 The number of digits in Long_Long_Float is 18 The size of the Long_Long_Float mantissa in bits is 61 However, the CPU's Long_Long_Float mantissa is 64 Can someone explain this? At first it looks like Long_Long_Float is going t= o be quadruple precision (128 bits) but then the precision results indicate= that it is only 3 digits better than Long_Float and has a rather small inc= rease in exponent range. And why is the Ada type using less mantissa bits t= han the hardware? Thanks, Jerry