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: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Truncation of FLOAT values Date: 1996/04/19 Message-ID: #1/1 X-Deja-AN: 148369846 references: <4l5nmq$fhv@inrou.erno.de> <4l6bjn$b96@cliffy.lfwc.lockheed.com> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-04-19T00:00:00+00:00 List-Id: Mike said "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." First, you clearly meant to say subtract rather than round, e.g. 2.3 - 0.5 = 1.8, conversion rounds to 2 = integer part of 2.3 but that's wrong, because 3.0 - 0.5 = 2.5, which is allowed in Ada 83 to round to 2 when you want 3. There is no trivial solution to this in Ada 83, which is why the truncation attribues was added to Ada 95.