From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Does Ada support endiannes?
Date: Wed, 14 Dec 2011 19:16:46 +0100
Date: 2011-12-14T19:16:46+01:00 [thread overview]
Message-ID: <bd598s0tsx36$.1cuu4z7458lbf$.dlg@40tude.net> (raw)
In-Reply-To: 0a7b55fd-1ecf-4a40-979c-12ce44071be9@p9g2000vbb.googlegroups.com
On Wed, 14 Dec 2011 08:16:02 -0800 (PST), Gerd wrote:
> On 13 Dez., 15:19, Gautier write-only <gautier_niou...@hotmail.com>
> wrote:
>
> Are you sure the "/" and mod would work correct?
Always. Arithmetic is complete in the sense that any possible function can
be implemented using these operations.
> Assume, that the Value 16#000000FF# shall be converted to
> 16#FF000000#
>
> Native : Integer := 16#000000FF#;
>
> Remote : Integer;
>
> Remote := 16#01000000# * ()Native mod 16#000000FF#); -- overflow!
Either it is not Integer (e.g. Unsigned_32) or else overflow is not an
error but a legal outcome indicating protocol error, for example. The
decision depends on the application.
Note that if you used a representation clause and/or Unchecked_Conversion,
you would have to use X'Valid attribute in order to check obtained value
for being an integer.
For all cases where arithmetic would raise Constraint_Error, X'Value should
yield false, which is not guaranteed of course. This is another reason why
not to use representation clauses, because some illegal representation
might get misinterpreted as proper values.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2011-12-14 18:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 8:57 Does Ada support endiannes? Gerd
2011-12-12 9:23 ` Niklas Holsti
2011-12-12 11:27 ` Dmitry A. Kazakov
2011-12-12 12:44 ` Gerd
2011-12-12 19:23 ` Jeffrey Carter
2011-12-13 14:25 ` Gerd
2011-12-13 14:19 ` Gautier write-only
2011-12-14 16:16 ` Gerd
2011-12-14 18:16 ` Dmitry A. Kazakov [this message]
2011-12-14 20:16 ` Gautier write-only
2011-12-15 11:27 ` Gerd
2011-12-15 13:01 ` Simon Wright
2011-12-15 13:37 ` Dmitry A. Kazakov
2011-12-15 20:12 ` Jeffrey Carter
2011-12-12 12:46 ` Gerd
2011-12-12 13:22 ` Dmitry A. Kazakov
2011-12-12 17:07 ` Charles H. Sampson
2011-12-12 18:33 ` Dmitry A. Kazakov
2011-12-14 5:19 ` Charles H. Sampson
2011-12-14 8:56 ` Dmitry A. Kazakov
2011-12-14 9:46 ` Simon Wright
2011-12-15 9:14 ` Charles H. Sampson
2011-12-15 9:46 ` Dmitry A. Kazakov
2011-12-25 21:42 ` Charles H. Sampson
2011-12-26 10:47 ` Dmitry A. Kazakov
2011-12-27 10:38 ` Georg Bauhaus
2011-12-27 12:35 ` Dmitry A. Kazakov
2012-01-04 4:33 ` Charles H. Sampson
2012-01-04 11:56 ` Dmitry A. Kazakov
2011-12-12 13:33 ` 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