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.9 required=5.0 tests=BAYES_00 autolearn=ham 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-7-bit Path: g2news1.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Truncating a fixed-point value Date: Fri, 09 Jul 2010 21:34:04 +0100 Organization: A noiseless patient Spider Message-ID: References: <732bea9d-aacb-4b87-b64b-657aabce6736@w31g2000yqb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Fri, 9 Jul 2010 20:34:04 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="KCXegvZb5vh43D+f3BR6Ew"; logging-data="22301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+REX/9TT5bdAkTXmRk1ZfpWjvXgkKU1XA=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:12oqIfGGLOgKJjYHadhLSKt9ZOY= sha1:TU26qHrLYNo7dxEavbqUijzhECs= Xref: g2news1.google.com comp.lang.ada:12296 Date: 2010-07-09T21:34:04+01:00 List-Id: Adam Beneschan writes: > 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 >= 0.0, and I need to > compute Floor(X) as an Integer. 'Truncation and 'Floor aren't defined > for fixed-point types; the type conversion Integer(X) rounds; and > Integer(X-0.5) fails if X=0.0. > > How do others do this? Or do I have to resort to an IF statement (or > conditional expression in Ada 2012) to handle the different cases? Looks as though Integer(X+0.5)-1 might do the trick ..