comp.lang.ada
 help / color / mirror / Atom feed
From: koch@math.utexas.edu (Hans Koch)
Subject: gnat and rounding up Long_Long_Float
Date: 16 Oct 2001 15:27:17 -0700
Date: 2001-10-16T22:27:17+00:00	[thread overview]
Message-ID: <3fc7873b.0110161427.2ff33bf8@posting.google.com> (raw)

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;



                 reply	other threads:[~2001-10-16 22:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox