Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!wisdom.BITNET!eyal From: eyal@wisdom.BITNET (Eyal mozes) Newsgroups: net.lang.ada Subject: Re: Numeric Conversion Message-ID: <8606120856.AA07663@ucbvax.Berkeley.EDU> Date: Thu, 12-Jun-86 04:57:27 EDT Article-I.D.: ucbvax.8606120856.AA07663 Posted: Thu Jun 12 04:57:27 1986 Date-Received: Sun, 15-Jun-86 07:15:56 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 27 > Now we have encountered a problem, trivial by nature, which has us > baffled. The problem is simply that of obtaining the integer part of > a positive fixed-point value. We can find no simple way of achieving > this in Ada: use of numeric conversion leads to uncertainty regarding > the direction of rounding (ARM 4.6 p7). Well, one way is to substract 0.5 from the number before converting it; this should always give you the correct result. Another way is to use the following function (which I write when I had to do the same thing a few months ago: function integer_part(value: real) return integer is temp: integer := integer(value); begin if real(temp) > value then return temp-1; else return temp; end if; end; Eyal Mozes BITNET: eyal@wisdom CSNET and ARPA: eyal%wisdom.bitnet@wiscvm.ARPA UUCP: ..!ucbvax!eyal%wisdom.bitnet