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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: getting same output as gfortran, long_float Date: Thu, 30 Apr 2015 20:12:47 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <1kxou0nloqg9c$.1x0itzgdrlosm$.dlg@40tude.net> Reply-To: nma@12000.org NNTP-Posting-Host: CV72NQ0GT7rQd8cP1ZYi/A.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.giganews.com comp.lang.ada:192980 Date: 2015-04-30T20:12:47-05:00 List-Id: On 4/30/2015 5:08 PM, Dmitry A. Kazakov wrote: > If GNAT allowed floating-point emulation, you could declare a custom type > of required precision: > > type My_Float is digits 34; -- 112 * lg(2) > > Which is advisable anyway in order to make your program portable. Using > built-in types is a bad idea and poor taste in most cases. > > Since GNAT does support emulation, at least not with the standard compiler > switches, you need a library for doing this. > I found that gfortran can do 128 bit floating point without the use of the compiler switch -fdefault-real-8. Which will map to similar thing as the above Ada construct: ------------------- PROGRAM foo IMPLICIT NONE REAL(KIND = 16) :: x !-- kind=16 tells it is double quad x = 12.0D0 * 0.0001D0/(1.0D0 * (1.0D0 - 0.1D0)**4 ) PRINT *, x END PROGRAM ------------------ gfortran -Wall foo2.f90 ./a.out 1.82898948331047112025871115292829927E-0003 So, I wonder what it would take to integrate this library to gnat to allow one to do type My_Float is digits 34; and just have it work as is. I assume this requires support and some changes at the compiler level (system.max_digits has to change for example)? Now it is set at 18 and the above gives compiler error. --Nasser