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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,66f08d1366903419,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-16 15:27:17 PST Path: archiver1.google.com!news1.google.com!postnews1.google.com!not-for-mail From: koch@math.utexas.edu (Hans Koch) Newsgroups: comp.lang.ada Subject: gnat and rounding up Long_Long_Float Date: 16 Oct 2001 15:27:17 -0700 Organization: http://groups.google.com/ Message-ID: <3fc7873b.0110161427.2ff33bf8@posting.google.com> NNTP-Posting-Host: 146.6.139.149 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1003271237 15681 127.0.0.1 (16 Oct 2001 22:27:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Oct 2001 22:27:17 GMT Xref: archiver1.google.com comp.lang.ada:14757 Date: 2001-10-16T22:27:17+00:00 List-Id: I hope that some gnat/floating point expert can help me with a question regarding the reliability of up/down rounding of Long_Long_Float (80 bit extended precision). I am running gnat under Linux on a Pentium system. My question only concerns the operations +,-,*,/, and maybe sqrt (needed for speed, the rest can be dealt with in software), and I am only interested in rounding up/down, since I need rigorous error bounds. For example, if I instruct the FPU to round up (using something like Round_Up - see below) and then perform numerous additions, multiplications, ..., can I assume that the only information lost (concerning the final result) is due to the FPU rounding up during these operations? >From all I have read so far about gnat, the 80X87 FPU, and the IEEE standard, this seems correct. But I could not find specific information in the case where denormalized numbers are involved (e.g. denormalized input, or underflow with normalized numbers). Does the FPU still round up correctly, in the sense that it returns a number that is no less than the actual result? If not, what does gnat do in this case? I hope that the error information is propagated to the program (I would be happy even if the program halted). Checking the FPU status registers after each operation would be too time consuming. An alternative would to be to use the exception masks in the FPU control register, but I assume that gnat will not let me control these. But maybe the "if not" does not not apply? Any relevane information would be highly appreciated. Thanks - Hans Koch P.S. Round_Up example with System.Machine_Code; use System.Machine_Code; procedure Round_Up is type Uns16 is mod 2**16; RoundUp: constant Uns16 := 16#1B3F#; begin Asm("fldcw %0",Inputs => Uns16'Asm_Input("m",RoundUp), Volatile => True); end Round_Up;