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: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: unsigned type Reply-To: anon@anon.org (anon) References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> <1eS1m.2153$j84.1865@nlpi061.nbdc.sbc.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Sun, 28 Jun 2009 23:21:27 GMT NNTP-Posting-Host: 12.64.120.167 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1246231287 12.64.120.167 (Sun, 28 Jun 2009 23:21:27 GMT) NNTP-Posting-Date: Sun, 28 Jun 2009 23:21:27 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:6692 Date: 2009-06-28T23:21:27+00:00 List-Id: "Natural" "Positive" definition: come from Mathematics and for Ada the Ada Language reference Manual ( Ada RM ) define in the Standard package. And all packages are defines as a child of the Standard package. Now for the Integer, Natural and Positive data types the value for a 32-bit system follows And in a 64 bit system the types would be based on "2 ** 64" instead of "2 ** 32". package Standard is type Integer is range -(2 ** 31) .. +(2 ** 31 - 1); subtype Natural is Integer range 0 .. +(2 ** 31 - 1); subtype Positive is Integer range 1 .. +(2 ** 31 - 1); ... end Standard ; In <1eS1m.2153$j84.1865@nlpi061.nbdc.sbc.com>, Gary Scott writes: >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