From: Simon Wright <simon@pushface.org>
Subject: Re: Interfaces.Shift_Left
Date: Mon, 12 Dec 2011 23:34:29 +0000
Date: 2011-12-12T23:34:29+00:00 [thread overview]
Message-ID: <m2pqft9xfe.fsf@pushface.org> (raw)
In-Reply-To: 18214312-82f5-45c4-b20d-cb530b500929@h3g2000yqa.googlegroups.com
awdorrin <awdorrin@gmail.com> writes:
> 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?
Ada doesn't have an easy way to do what you ask; one way you can do it
is by instantiating Ada.Unchecked_Conversion, which is deliberately
obvious so that reviewers know that they have to take more care than
usual.
It'd be much easier if Data was Unsigned_32 to start with, and if
instead of INT_PTR you had an Unsigned_32_Ptr.
next prev parent reply other threads:[~2011-12-12 23:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 22:30 Interfaces.Shift_Left awdorrin
2011-12-12 23:34 ` Simon Wright [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox