comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Fixed Point Range
Date: 1997/10/26
Date: 1997-10-26T00:00:00+00:00	[thread overview]
Message-ID: <dewar.877883225@merv> (raw)
In-Reply-To: mheaney-ya023680002510972018380001@news.ni.net


Matthew Heany says

  <<Consider this type:

   type Fixed is delta 1.0 range 0.0 .. 256.0;
   for Fixed'Small use 1.0;

  In the code example below, I print out the values of Fixed'Last and
  Fixed'Base'Last.  The output is:

  T'Size:  8
  T'Base'Size:  16

  T'First:  0.0
  T'Last:  255.0

  T'Base'First: -32768.0
  T'Base'Last:  32767.0 >>

The above output is correct, i.e. it is consistent with one of
several possible sets of output permitted by the RM in this case.

  <<My question is this.  I interpret the RM to mean that Fixed'Last is the
  smaller of 256.0 (the expression specified the type declaration) and
  32767.0 (the value of Fixed'Base'Last).  Yet the value of Fixed'Last is
  255.0.  Why?>>

You read the RM wrong, it explicitly permits 255.0 in this case, with
exactly this situation in mind.

  <<Or perhaps I printed out the value of the base range incorrectly.  Is there
  a preferred method to Fixed'Base'Image (Fixed'Base'Last)?  Maybe the base
  range really is -256.0 .. 255.0, and just my output is bad.>>

Your output is correct

Incidentally, I suggest that if you are interested in finding out more
about fixed point, you will find it helpful to read the special issue
report I did for the SEI on this subject during the Ada 9x development.





  reply	other threads:[~1997-10-26  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-25  0:00 Fixed Point Range Matthew Heaney
1997-10-26  0:00 ` Robert Dewar [this message]
1997-11-05  0:00   ` Mark Lusti
1997-11-04  0:00     ` Matthew Heaney
replies disabled

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