From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Unclear error message - please help
Date: 15 Oct 2005 21:10:36 -0400
Date: 2005-10-15T21:10:36-04:00 [thread overview]
Message-ID: <wcczmpafer7.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: h84lk1tqgofrhgabm8q3sqbb80li6733bh@4ax.com
Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
> On Mon, 10 Oct 2005 08:02:07 +1000, Brian May <bam@snoopy.apana.org.au>
> declaimed the following in comp.lang.ada:
>
> >
> > I read the above links but didn't see why a range 0..65535 requires 17
> > bits.
>
> I haven't dug up the reference books, but I seem to recall that, for
> a non-MOD type, the /base/ storage is assumed to be signed. So...
> 0..65535 implies a base of -65535..65535; with a run-time check that no
> negatives are allowed.
>
> Ah... Page 39 of my old reference manual
>
> """
> A signed_integer_type_definition defines an integer type whose base
> range includes at least the values of the simple_expressions and is
> symmetric about zero, excepting possibly an extra negative value. A
> signed_integer_type_definition also defines a constrained first subtype
> of the type, with a range whose bounds are given by the values of the
> simple_expressions, converted to the type being defined.
> """
>
> Keywords: base range; symmetric about zero.
Right. But don't confuse the base range with the memory size of
values/objects of that subtype.
The base range determines how arithmetic works: overflow will not
happen, so long as you stay within that base range. So, for example,
(X+Y)/2 will not overflow, so long as the value of X+Y is within the
base range.
But the object X might be stored in a smaller number of bits than the
base range requires. Normally, the compiler will store X in a register
or memory location that matches the base range, for efficiency, but you
can request smaller memory size with all kinds of rep clauses/pragmas.
Anyway, I think the original post showed a [sub]type derived from
Integer, so it will have the same base range as Integer (perhaps 32
bits).
- Bob
prev parent reply other threads:[~2005-10-16 1:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-17 21:11 Unclear error message - please help Alfred Hilscher
2005-09-17 21:44 ` Gene
2005-09-17 22:02 ` Ludovic Brenta
2005-09-18 2:32 ` Robert A Duff
2005-10-08 19:39 ` Alfred Hilscher
2005-10-08 20:15 ` Björn Persson
2005-10-09 7:34 ` Martin Krischik
2005-10-08 21:28 ` Dmitry A. Kazakov
2005-10-08 23:58 ` Robert A Duff
2005-10-09 7:29 ` Martin Krischik
2005-10-09 14:24 ` Robert A Duff
2005-10-09 22:02 ` Brian May
2005-10-10 16:49 ` Martin Krischik
2005-10-10 22:20 ` Brian May
2005-10-11 5:48 ` Martin Dowie
2005-10-11 18:03 ` Martin Krischik
[not found] ` <h84lk1tqgofrhgabm8q3sqbb80li6733bh@4ax.com>
2005-10-16 1:10 ` Robert A Duff [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox