comp.lang.ada
 help / color / mirror / Atom feed
From: john schneider <j-schneider@ti.com>
Subject: Re: Help with fixed types...insufficient model numbers?
Date: 1997/04/01
Date: 1997-04-01T00:00:00+00:00	[thread overview]
Message-ID: <3341605F.167EB0E7@ti.com> (raw)
In-Reply-To: 5hrdic$sr@hacgate2.hac.com


John,
  Re-check what you are asking for --- your example, specifies a
range of 0.0 .. 2.0**31 - 1.0.  This range already requires 30 bits
to store just integer values.  Your delta of 0.0000256 asks for an
additional 39000+ values per integer!  What you asked for obviously
won't fit in a 32-bit quantity.

First, verify that your compiler really allows you to specify a
type'SMALL that is not a power of two -- some (i.e. mine) will not.
Generally, the compiler will reserve for the fractional portion of
a value, as many bits as is needed to store the largest power of 2
which is smaller than the "delta" you specify.  Your request
for 1E-3, or 1/1000. Means that the compiler will use 1/1024, which
requires 10 bits, leaving 22 bits to represent the range of your
value and the sign of the number (remember, base types need symmetry
around 0, even when you are not using negatives).  Therefore, you
should be able to specify a range of -2.0**21 .. 2.0**21 - 1.0.

John Gluth wrote:
> 
> Can somebody help me understand this model number thing?
> 
> I'm using the Rational Apex environment and compiling for
> a PowerPC 603e.
> 
> Basic problem:
> 
> I've got a 64 bit timer (running at 10 MHz)
> I don't need 64 bits of resolution (1 ms is adequate).
> 
> I originally planned to use 32 bits of the timer, shifting left
> 8 bits, leaving me with LSB = 25.6 microseconds, and a rollover
> time of around 8 hours.
> 
> So I tried doing this:
> 
> Time_LSB : constant := 0.0000256;
> 
> type Time_Type is delta Time_LSB range 0.0 .. 2.0**31 - 1.0;
> for Time_Type'Size use 32;
> for Time_Type'Small use Time_LSB;
> 
> This leads to a complaint from the compiler along the lines of
> 'insufficient model numbers'
> 
> I did a little more research.  SAFE_SMALL is defined as 1.000000000E-04
> 
> As I understand it, SAFE_SMALL would indicate the smallest value for
> for 'Small that would give me enough model numbers to get the full
> range of values (-2.0**31 .. 2.0**31 -1.0)...true?
> 
> I did a little experimenting, and found that if I use:
> 
> Time_LSB : constant := 1.0;     => No problem with 0..2.0 ** 31 - 1.0
> Time_LSB : constant := 0.0001;  => Insufficient model numbers
>                                    (even using 0..2.0**30, 2.0**29, etc.)
> Time_LSB : constant := 0.1;     => Still insufficient model numbers
>                                    down to 2.0**29, etc.
> 
> How does one determine what the maximum allowable range is?
> 
> There is an attribute LAST, which is listed as 214748.3647
> Is this my upper limit?  If so, why?
> 
> What's the largets upper bound I can get with a 32 bit fixed number and
> an LSB (Small) of around 1E-3?
> 
> Thanks,
> 
> John


John Schneider
j-schneider@ti.com

The opinions are mine, but you are welcome to share them.




  reply	other threads:[~1997-04-01  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-01  0:00 Help with fixed types...insufficient model numbers? John Gluth
1997-04-01  0:00 ` john schneider [this message]
1997-04-02  0:00   ` Robert Dewar
1997-04-01  0:00 ` Robert Dewar
replies disabled

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