comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <dewar@gnat.com>
Subject: Re: Fixed Point Numbers
Date: 1999/05/28
Date: 1999-05-28T00:00:00+00:00	[thread overview]
Message-ID: <7il2g3$pff$1@nnrp1.deja.com> (raw)
In-Reply-To: z64AzHA$uZT3Ewor@the-shieling.demon.co.uk

In article <z64AzHA$uZT3Ewor@the-shieling.demon.co.uk>,
  Philip Bradley <philip@the-shieling.demon.co.uk> wrote:
> What is the impact of the differing deltas in the following
type
> definitions :
>
> type Long_Type is delta 180.0/2**31 range -180.0 .. 180.0;
> for Long_Type'Small use 180.0/2**31;
> for Long_Type'Size use 32;

Right, GNAT will allow this, and indeed even if you did not
have the Size clause would use a size of 32. What GNAT does
is to include the end points, UNLESS this would cause the size
to get awkwardly bigger (32 to 33 bits certainly counts :-)
in which case it will exclude end points as allowed by the RM.

This behavior is explicitly allowed (and indeed one may say
intended, since this is the reason that a compiler is allowed
to exclude the end points), but unfortunately, compilers are
not required to take this reasonable approach, and you may
have to manually exclude the end point.

The representations should be identical in either case, so the
second form is the more portable, if less convenient, form.

Robert Dewar
Ada Core Technologies


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  reply	other threads:[~1999-05-28  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-27  0:00 Fixed Point Numbers Philip Bradley
1999-05-28  0:00 ` Robert Dewar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-05-27  0:00 Robert I. Eachus
1999-06-08  0:00 ` Robert A Duff
1999-06-09  0:00   ` Robert I. Eachus
replies disabled

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