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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ed9aea76d58b2ba,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-13 00:41:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!enst.fr!not-for-mail From: Duncan Sands Newsgroups: comp.lang.ada Subject: IEEE arithmetic Date: Fri, 13 Sep 2002 09:40:52 +0200 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-Trace: avanie.enst.fr 1031902862 9360 137.194.161.2 (13 Sep 2002 07:41:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 13 Sep 2002 07:41:02 +0000 (UTC) Return-Path: User-Agent: KMail/1.4.3 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:28905 Date: 2002-09-13T09:40:52+02:00 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.