comp.lang.ada
 help / color / mirror / Atom feed
* Interfaces.Shift_Left
@ 2011-12-12 22:30 awdorrin
  2011-12-12 23:34 ` Interfaces.Shift_Left Simon Wright
  2011-12-13 12:00 ` Interfaces.Shift_Left Brian Drummond
  0 siblings, 2 replies; 22+ messages in thread
From: awdorrin @ 2011-12-12 22:30 UTC (permalink / raw)


Perhaps I'm just brain-dead after staring at code all day - but I'm
currently stumped and hoping someone could point me in the right
direction.

I've been trying to update old Ada code to Ada95 standards and wanted
to replace the calls to a custom C 'bit' library with the methods
available in the Interface package.

The interface package only takes unsigned values as parameters, which
I figured is fine since at a bit level sign doesn't really matter, but
looks like I was wrong, as I'm now encountering a constraint error
after a Shift_Left operation's results are casted back to an
Integer_32 type.

The code is similar to the following:

Cur_Word := (Cur_Word OR Shift_Left( Unsigned_32(Data),
Bits_To_Shift));
INT_PTR.all := Integer_32(Cur_Word);

I understand that the result from the shift_left is a negative number,
so it is being seen by Ada as a  large positive number ( > (2^31-1))
which is why I'm getting the Constraint error;

Maybe its my history with C that is confusing me, but shouldn't there
be an easy way to cast the value back to a negative Integer_32 from an
Unsigned_32?

Thanks!



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-12-21  7:29 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12 22:30 Interfaces.Shift_Left awdorrin
2011-12-12 23:34 ` Interfaces.Shift_Left Simon Wright
2011-12-13  1:36   ` Interfaces.Shift_Left Adam Beneschan
2011-12-13 12:00 ` Interfaces.Shift_Left Brian Drummond
2011-12-13 13:15   ` Interfaces.Shift_Left awdorrin
2011-12-13 21:48     ` Interfaces.Shift_Left Randy Brukardt
2011-12-14 18:28       ` Interfaces.Shift_Left awdorrin
2011-12-14 22:49         ` Interfaces.Shift_Left Randy Brukardt
2011-12-15  9:51           ` Interfaces.Shift_Left Niklas Holsti
2011-12-16  0:23             ` Interfaces.Shift_Left Randy Brukardt
2011-12-18 20:47               ` Interfaces.Shift_Left Niklas Holsti
2011-12-20  0:38                 ` Interfaces.Shift_Left Randy Brukardt
2011-12-20  2:18                   ` Interfaces.Shift_Left Shark8
2011-12-20 10:08                   ` Interfaces.Shift_Left Dmitry A. Kazakov
2011-12-20 19:38                   ` Interfaces.Shift_Left Niklas Holsti
2011-12-20 20:46                     ` Interfaces.Shift_Left Niklas Holsti
2011-12-20 21:13                       ` Interfaces.Shift_Left Simon Wright
2011-12-20 21:08                     ` Interfaces.Shift_Left Simon Wright
2011-12-20 23:26                       ` Interfaces.Shift_Left Randy Brukardt
2011-12-20 23:36                     ` Interfaces.Shift_Left Randy Brukardt
2011-12-21  0:44                       ` Interfaces.Shift_Left Georg Bauhaus
2011-12-21  7:23                       ` Interfaces.Shift_Left AdaMagica

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