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-29 07:36:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Decimal number of interger? Date: Mon, 29 Oct 2001 10:36:54 -0500 Organization: AverCom Corp, a Titan company Message-ID: <3BDD7796.AF6ABCE4@avercom.net> References: <3BD70DE5.C2D2B6FD@ida.his.se> NNTP-Posting-Host: 192.168.24.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 1004369811 18241 192.168.24.34 (29 Oct 2001 15:36:51 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 29 Oct 2001 15:36:51 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:15348 Date: 2001-10-29T15:36:51+00:00 List-Id: a98mican@ida.his.se wrote: > > Hi! > How do I determine weather the result from a function has a decimal part > or not? > 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" > > Thanks in advance! > /Michael Andersson The attribute function S'Remainder(x, y) can be used to get the "fractional" part, as follows: if Float'Remainder(X, 1.0) = 0.0 then -- X has no fractional part else -- X has a fractional part end if; On the other hand, you are using two relatively expensive floating point operations to determine something that might be done more cheaply in some other way. E.g., getting the exponent (presuming the Machine_Radix is 2, which it almost certainly is unless you are on a mainframe) using Float'Exponent() and then using Float'Compose() to build a new value that is 2^exponent. Alternatively, Float'Fraction might be the perfect function, because Float'Fraction(width-1) will be exactly 0.50 in the case of interest (again, presuming Machine_Radix is 2). -- -Tucker Taft stt@avercom.net http://www.avercom.net Chief Technology Officer, AverCom Corporation (A Titan Company) Bedford, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/~stt)