comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jeffrey.carter@boeing.com>
Subject: Re: Decimal number of interger?
Date: Wed, 24 Oct 2001 23:35:37 GMT
Date: 2001-10-24T23:35:37+00:00	[thread overview]
Message-ID: <3BD75049.44EC5A34@boeing.com> (raw)
In-Reply-To: K%EB7.65302$gT6.33413933@news1.rdc1.sfba.home.com

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



  reply	other threads:[~2001-10-24 23:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-24 17:46 Decimal number of interger? a98mican
2001-10-24 19:54 ` tmoran
2001-10-24 23:35   ` Jeffrey Carter [this message]
2001-10-25  1:38 ` DuckE
2001-10-29 15:36 ` Tucker Taft
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox