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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,245c84afd1e393ce X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: What about big integers in Ada 2005? References: <1581461.uQ1jN63t33@linux1.krischik.com> From: Brian May Date: Sun, 02 Oct 2005 10:48:40 +1000 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:qeEecbM4tdUrmRED94E4QVdKSG4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1128214283 202.173.153.89 (2 Oct 2005 10:51:23 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!news-south.connect.com.au!duster.adelaide.on.net!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:5329 Date: 2005-10-02T10:48:40+10:00 List-Id: >>>>> "Martin" == Martin Krischik writes: Martin> You are mistaken here. i.E GNAT supports 64 integers for Martin> 32 bit CPUs. It's all up to the particular compiler. In Martin> theory you could create an Ada compiler which supports Martin> intergers up to the memory limit - it would still conform Martin> to the standart. Question (from writing a communications protocol with a high level programming language that turned out to a an extremely poor choice[1]): Does GNAT support both "unsigned" and "signed" 64 bit numbers on 32 bit CPUs? The reason I ask is because the protocol specs say some numbers might be 64 bit, and sometimes they are signed, and other times that might be unsigned. I am just curious if how well Ada could cope with this. Notes: [1] PHP. As far as I can tell it only supports signed 32 bit numbers on 32 bit platforms[1]. [2] Fortunately, 32 bit numbers are probably OK for my client. This is kind of ugly though, as I have to store the numbers in a mysql database (signed/unsigned up to 64 bit[3]). My current approach is to turn it into a positive number and store it in an unsigned 64 bit field, with another field to indicate that the number is negative. Unfortunately, the negative number 8000 0000 (hex) can't be represented as a positive number in a signed 32 bit integer :-(. So I transform the number into 7FFF FFFF (hex) instead. This results in it being out by one. [3] Yes, even though the current code doesn't support 64bit, I have designed the database to support it properly. -- Brian May