comp.lang.ada
 help / color / mirror / Atom feed
* IEEE arithmetic
@ 2002-09-13  7:40 Duncan Sands
  2002-09-13 13:03 ` Georg Bauhaus
  2002-09-13 15:59 ` Robert A Duff
  0 siblings, 2 replies; 6+ messages in thread
From: Duncan Sands @ 2002-09-13  7:40 UTC (permalink / raw)


I have two problems:

(1) IEEE 754 compliant systems have four rounding modes
for arithmetic operations: round to even (default), round to zero,
round to +infinity, round to -infinity.  How to change the rounding
mode in a fairly portable way?  I am happy if the method is specific
to the GNAT compiler.

Note: the GNU C library has a routine for doing this, but the constants
you feed it to choose the rounding mode seem to have architecture
dependent values (macros are used to give these values common names).
One solution would be to have a way to get hold of the values given by the
macros inside of the Ada program, but I don't know how to do this.

(2) Given a universal real number x (suppose it is in the safe range of some
floating point type T), how to find model numbers a, b of type T such that
a <= x <= b and a and b are adjacent (i.e. [a,b] is a smallest interval
representable in type T and containing x)?  At the moment the best I can do is:

a, b, y : T;

y := T(x);
a := T'Pred (y);
b := T'Succ (y);

Then indeed a <= x <= b but a and b are not adjacent: there is a model
number between them.

Thanks for your help,

Duncan.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-09-14  0:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-13  7:40 IEEE arithmetic Duncan Sands
2002-09-13 13:03 ` Georg Bauhaus
2002-09-13 13:19   ` Duncan Sands
2002-09-13 15:59 ` Robert A Duff
2002-09-13 16:06   ` Duncan Sands
2002-09-14  0:46     ` Robert A Duff

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