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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dd2096591176a662 X-Google-Attributes: gid103376,public From: john schneider Subject: Re: Help with fixed types...insufficient model numbers? Date: 1997/04/01 Message-ID: <3341605F.167EB0E7@ti.com>#1/1 X-Deja-AN: 229985383 References: <5hrdic$sr@hacgate2.hac.com> Newsgroups: comp.lang.ada Date: 1997-04-01T00:00:00+00:00 List-Id: 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.