From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c5f68ab74d5099ee,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.2 with SMTP id gm2mr10634873pbc.4.1323729155287; Mon, 12 Dec 2011 14:32:35 -0800 (PST) Path: lh20ni15506pbb.0!nntp.google.com!news2.google.com!postnews.google.com!h3g2000yqa.googlegroups.com!not-for-mail From: awdorrin Newsgroups: comp.lang.ada Subject: Interfaces.Shift_Left Date: Mon, 12 Dec 2011 14:30:51 -0800 (PST) Organization: http://groups.google.com Message-ID: <18214312-82f5-45c4-b20d-cb530b500929@h3g2000yqa.googlegroups.com> NNTP-Posting-Host: 192.91.173.42 Mime-Version: 1.0 X-Trace: posting.google.com 1323729155 15298 127.0.0.1 (12 Dec 2011 22:32:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 12 Dec 2011 22:32:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h3g2000yqa.googlegroups.com; posting-host=192.91.173.42; posting-account=YkFdLgoAAADpWnfCBA6ZXMWTz2zHNd0j User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-12-12T14:30:51-08:00 List-Id: 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!