comp.lang.ada
 help / color / mirror / Atom feed
From: Michal Nowak <vinnie@inetia.pl>
To: "comp.lang.ada usegroup->mailing list gateway"
	<comp.lang.ada@ada.eu.org>
Subject: Re: Constraint_Error in arithmetic expressions
Date: Sun, 19 Jan 2003 14:41:45 +0100
Date: 2003-01-19T14:41:45+01:00	[thread overview]
Message-ID: <mailman.8.1042983074.265.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <wcc8yxqgcsp.fsf@shell01.TheWorld.com>

On 2003-01-12 at 23:37 Robert A Duff wrote:

>> Suppose that if I declare:
>>    type T is range 1 .. 200;
>>    A : T := 150;
>>    B : T := 150;
>> the compiler may choose 1 byte (0 .. 255) or 2 bytes (0 .. 65535) for
>> example, for the base subtype.
>
>No.  "is range" declares a signed integer type, and for signed integers,
>the base range is always symmetric about zero (or has an extra negative
>value).  So the minimal base range the compiler can choose in this case
>is -200..200.  It can choose a wider range.  Compilers usually choose a
>range that is supported by the hardware.

Oh, in fact, I found appropriate RM section.

Now comes another curious question -
Why the base range is symmetric about zero?
Is it because that it is for signed integer? Are there any reasons 
for it?
I'm asking, because suppose I have a 16 bit machine. 
Now I want to declare:
   type T is range 2**16 - 10 .. 2**16 - 1;

but it is not possible. However, if the base type could be in range
0 .. 2**16 - 1 it could be possible.

Thank you for your previous answer,
  - Michal


"Beyond 100,000 lines of code you
should probably be coding in Ada"
   - P. J. Plauger






  reply	other threads:[~2003-01-19 13:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-12 12:36 Constraint_Error in arithmetic expressions Michal Nowak
2003-01-12 23:37 ` Robert A Duff
2003-01-19 13:41   ` Michal Nowak [this message]
2003-01-21 18:48     ` Robert A Duff
replies disabled

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