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: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!dc3peer1.nntp.savvis.net!peer.nntp.savvis.net!nlpi057.nbdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!nlpi071.nbdc.sbc.com!nlpi061.nbdc.sbc.com.POSTED!cfe18fef!not-for-mail From: Gary Scott Organization: Home User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: unsigned type References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <1eS1m.2153$j84.1865@nlpi061.nbdc.sbc.com> NNTP-Posting-Host: 68.94.36.251 X-Complaints-To: abuse@prodigy.net X-Trace: nlpi061.nbdc.sbc.com 1246228477 ST000 68.94.36.251 (Sun, 28 Jun 2009 18:34:37 EDT) NNTP-Posting-Date: Sun, 28 Jun 2009 18:34:37 EDT X-UserInfo1: SCSYQN_@OXWQB_LZBZOB_QDBAJT@QDDMEPWXODMMHXMTWA]EPMTKAH_[JTXDX_KI\VB]JBVMS^YT_G[CZVWAOS\DHFWEH]@KGXYHB\_CMDSFABP^J[AHHRKARLE_JDBLJ\XA[JRMEI]MGJSPB\Y]^KG\@S^@VQKI_Q[G@@_ACSARASDEFLBJ]S\GFNTUAVBL Date: Sun, 28 Jun 2009 17:34:29 -0500 Xref: g2news2.google.com comp.lang.ada:6689 Date: 2009-06-28T17:34:29-05:00 List-Id: tmoran@acm.org wrote: >>I am trying to declare a type as unsigned using Ubuntu 9.04 GNAT >>compiler. I know Ada does not have a type CARDINAL, but I thought it >>had a type Unsigned. > > > Ada's equivalent is Natural. If Sorry for the naive question. I'm curious as to the reason for the term "natural". "Unnatural" would seem more descriptive :) > Lowest : Natural := 0; > Highest : Natural := Natural'last; > then > Lowest := Lowest-1; -- will raise an exception > Highest := Highest+1; -- ditto > > (Note that Gnat by default is not a legal Ada compiler because it doesn't > check for and raise the exception. You need a command line parameter > -gnato to make it act like Ada.) > > The standard Ada package Interfaces has hardware-oriented types > Unsigned_8, Unsigned_16, etc but those are modular types so if > Empty_Word : Interfaces.Unsigned_16 := 0; > Full_Byte : Interfaces.Unsigned_8 := 255; > then > Empty_Word-1 will be 65535. > Full_Byte+1 will be 0. > with no exceptions raised. > > You can also declare your own application oriented non-negative types > type Ratings is range 1 .. 10; > or modular types > type Degrees is mod 360; -- 0 .. 359 wrapping around -- Gary Scott mailto:garylscott@sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford