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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cb3f9900b9cf2da6 X-Google-Attributes: gid103376,public From: l117593@cliffy.lfwc.lockheed.com (Cordes MJ) Subject: Re: Truncation of FLOAT values Date: 1996/04/18 Message-ID: <4l6bjn$b96@cliffy.lfwc.lockheed.com>#1/1 X-Deja-AN: 148244257 references: <4l5nmq$fhv@inrou.erno.de> organization: Lockheed Martin Tactical Aircraft Systems newsgroups: comp.lang.ada Date: 1996-04-18T00:00:00+00:00 List-Id: Franz Kruse (Franz.Kruse@erno.de) wrote: : Is there a simple way in Ada 83 to determine the integer part or the fraction part : of a FLOAT value? : A conversion to INTEGER cannot be used, because it rounds. : Franz Kruse If your compiler rounds, then you can simply add 0.5 to the FLOAT value prior to converting it an INTEGER. You get the fractional part by converting the result back to FLOAT and subtracting it from the original FLOAT value. Seems pretty simple to me (although it doesn't use any fancy Ada features) ;) P.S., take care to check how your compiler rounds for numbers less than zero and how it rounds (with the addition of 0.5) at the upper and lower limits of the valid range. Mike Cordes ###