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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9ea5d59767aa4a7d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!z26g2000vbk.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Truncating a fixed-point value Date: Fri, 9 Jul 2010 15:58:36 -0700 (PDT) Organization: http://groups.google.com Message-ID: <77afc4ca-92d2-424f-8bdd-248fc77cf05e@z26g2000vbk.googlegroups.com> References: <732bea9d-aacb-4b87-b64b-657aabce6736@w31g2000yqb.googlegroups.com> NNTP-Posting-Host: 174.28.205.195 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1278716316 15807 127.0.0.1 (9 Jul 2010 22:58:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 9 Jul 2010 22:58:36 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z26g2000vbk.googlegroups.com; posting-host=174.28.205.195; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.10) Gecko/20100504 Firefox/3.5.10 ( .NET CLR 3.5.30729; .NET CLR 4.0.20506),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12301 Date: 2010-07-09T15:58:36-07:00 List-Id: On Jul 9, 1:06=A0pm, Adam Beneschan wrote: > I must be suffering from an embarrassing mental block, because I'm > sure there's a simple solution, but I can't see what it is. > > I have a value X of a fixed-point type, X >=3D 0.0, and I need to > compute Floor(X) as an Integer. =A0'Truncation and 'Floor aren't defined > for fixed-point types; the type conversion Integer(X) rounds; and > Integer(X-0.5) fails if X=3D0.0. > > How do others do this? =A0Or do I have to resort to an IF statement (or > conditional expression in Ada 2012) to handle the different cases? > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Adam I'd think that 1-Integer(X+0.5) would work... wouldn't it?