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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c81958079621fd4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-24 16:55:43 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-hub.siol.net!zur.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Decimal number of interger? X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3BD75049.44EC5A34@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3BD70DE5.C2D2B6FD@ida.his.se> Mime-Version: 1.0 Date: Wed, 24 Oct 2001 23:35:37 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:15155 Date: 2001-10-24T23:35:37+00:00 List-Id: tmoran@acm.org wrote: > > >How do I determine weather the result from a function has a decimal part > >or not? > x : float := function_value(y); > begin > if float(integer(x)) = x then -- decimal part of x is zero > > >I want to use the log function to se weather the width of the terrain is > >(2^x)+1. In order to do this I want to use the following: > >log2(width-1) = "float without decimal part" > test : interfaces.unsigned_32 := interfaces.unsigned_32(width-1); > begin > if (test and (test-1)) = 0 then -- test (ie, width-1) is a power of 2. This will probably work for the values expected from such an application, but for the general case in which Width - 1 may not fit in any integer type, the floating-point attribute 'Floor (or 'Truncation, if the value may be negative) yields a floating-point value with no fractional part. -- Jeffrey Carter