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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b2923d60cb81694b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Unsigned Integer Restraint Errors Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1173712032.183064.264340@8g2000cwh.googlegroups.com> <1173726806.656979.305660@8g2000cwh.googlegroups.com> Date: Mon, 12 Mar 2007 22:04:15 +0100 Message-ID: <1t64hfr3a6yc9.1a9r7r1p9i4cq$.dlg@40tude.net> NNTP-Posting-Date: 12 Mar 2007 22:04:12 CET NNTP-Posting-Host: 0a4dc212.newsspool4.arcor-online.net X-Trace: DXC=\AJPmWFhFR8RadXUBHgFh34IUKHd9DNcfSJ;bb[5IRnRBaCd9b7jLZYP=G3]8cL1MZiQR8 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14497 Date: 2007-03-12T22:04:12+01:00 List-Id: On 12 Mar 2007 12:13:26 -0700, frikk wrote: > Thank you for the input. This leaves me with 2 questions: > 1. If my input is 2**35, wouldn't this still render the Integer type > inaccurate? The goal is to be able to use 64 bit integers... I'm > referring to your example of UNSIGNED_LONG_INT := UNSIGNED_LONG_INT > (Integer'(X)); I don't understand what are you trying to achieve. Where the input comes from, and what type it has. I see only two possibilities: 1. The input type is UNSIGNED_LONG_INT, where is the problem? It is in the range. -5 in your example is not a number, it is an expression of UNSIGNED_LONG_INT and its result is in the range of. If the semantics of "-" bothers you, redefine it: function "-" (Left : UNSIGNED_LONG_INT) return UNSIGNED_LONG_INT is begin if Left = 0 then return Left; else raise Constraint_Error; -- No wrapping end if; end "-"; or else disallow it altogether: function "-" (Left : UNSIGNED_LONG_INT) return UNSIGNED_LONG_INT is abstract; 2. The type is some different type. You have to convert it to UNSIGNED_LONG_INT and if its value is outside UNSIGNED_LONG_INT'Range you will get Constraint_Error. Again, no problem in sight. It is safe in all cases. ------- When you use Integer, it is to expect that on most machines Integer'Last