From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: The right way to handle this difference in Ada
Date: Thu, 22 Jul 2004 13:34:17 GMT
Date: 2004-07-22T13:34:17+00:00 [thread overview]
Message-ID: <tnPLc.99086$dP1.337387@newsc.telia.net> (raw)
In-Reply-To: <cdo4ic$q8f$1@e3k.asi.ansaldo.it>
vic wrote:
> a: unsigned_int_12_type;
> b: unsigned_int_12_type;
>
> If the code must perform a difference between a and b, say:
>
> c := a-b
>
> 1) which should be the type of c? I think it should be something like:
>
> type signed_int_12_type is range -unsigned_int_12'last ..
> unsigned_int_12'last.
It all depends on what values are sensible for c to have. If for example
c should never be negative, then it's an error if b is greater than a in
the subtraction. Then you can declare c as unsigned_int_12_type, and if
the subtraction ever yields a negative value you'll get a Constraint_Error.
--
Björn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
next prev parent reply other threads:[~2004-07-22 13:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-22 10:23 The right way to handle this difference in Ada vic
2004-07-22 11:53 ` Eric Jacoboni
2004-07-22 12:07 ` Nick Roberts
2004-07-22 13:03 ` Dmitry A. Kazakov
2004-07-22 13:22 ` Eric Jacoboni
2004-07-22 13:34 ` Dmitry A. Kazakov
2004-07-22 13:34 ` Björn Persson [this message]
2004-07-22 17:52 ` Georg Bauhaus
2004-07-22 18:10 ` Georg Bauhaus
2004-07-23 3:41 ` Steve
2004-07-23 12:47 ` Marius Amado Alves
2004-07-24 3:14 ` 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