comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Restarting Tread: Why isn't this program working with Unchecked_Converstion
Date: Fri, 16 Jan 2009 09:26:25 -0800 (PST)
Date: 2009-01-16T09:26:25-08:00	[thread overview]
Message-ID: <c12e233b-e70e-490a-8f01-b9576df79ab1@l33g2000pri.googlegroups.com> (raw)
In-Reply-To: 70172b19-360c-4eba-815c-ede747c3bcdf@w39g2000prb.googlegroups.com

On Jan 16, 5:08 pm, ChristopherL <clusard...@aol.com> wrote:
> On Jan 16, 7:11 am, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>
> >    type Signed_8 is range - 2**7 .. 2**7 - 1;
> >    for Signed_8'Size use 8;
>
> I didn't use the second line in my program! Without it, my system
> uses 10 bits for this. I'm going to use my solution for now.
>
> Also experimenting on my own, if I only make the below change the
> variable Result has a value of -62 and not as above (-56).
>
> --  type Short_integer1 is range 0.. ((2 ** 8) - 1);
> --  for Short_Integer1'Size use 8;
>
>   type Short_integer1 is mod 2 ** 8;
>   for Short_Integer1'Size use 8;
>
> What does the following line of code do? It's new to me and have to
> know!
>
> type Short_integer1 is mod 2 ** 8;
>
> Chris L.

"mod" indicates a 'modular' type - i.e. unsigned, with wrap-round
semantics (no exceptions). Analogous to C 'unsigned'. Useful for
masking - using 'and', 'or', etc.

If you want an unsigned 8-bit integer with those semantics, you can
use the predefined type Interfaces.Unsigned_8. The package
'Interfaces' name indicates that you are 'close to the metal' in some
why and you actually _care_ about the size of objects your
manipulating.

There is a very good Wikibook on Ada you know...

http://en.wikibooks.org/wiki/Ada_Programming

and in particular:

http://en.wikibooks.org/wiki/Ada_Programming/Types/mod

Cheers
-- Martin



  parent reply	other threads:[~2009-01-16 17:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <83d19cd8-71ca-43c1-a3eb-05832290e565@r36g2000prf.googlegroups.com>
2009-01-15 21:22 ` Restarting Tread: Why isn't this program working with Unchecked_Converstion Jeffrey R. Carter
     [not found]   ` <37daf0e6-39b8-4820-a7fc-b6c5decf1ed8@q19g2000yqi.googlegroups.com>
2009-01-16  0:22     ` Jeffrey R. Carter
2009-01-16  1:37 ` Restarting Tread: Why isn't this program working with anon
     [not found] ` <40239b21-b265-467f-9b27-5890fb2f4c67@w1g2000prm.googlegroups.com>
2009-01-16  2:27   ` Restarting Tread: Why isn't this program working with Unchecked_Converstion Adam Beneschan
     [not found]     ` <9069fcf7-4257-4439-ad4a-8d7c8c17f5cf@v5g2000pre.googlegroups.com>
2009-01-16 15:11       ` Ludovic Brenta
2009-01-16 16:23         ` Martin
     [not found]         ` <70172b19-360c-4eba-815c-ede747c3bcdf@w39g2000prb.googlegroups.com>
2009-01-16 17:24           ` Ludovic Brenta
2009-01-16 17:26           ` Martin [this message]
2009-01-16 17:34           ` Georg Bauhaus
2009-01-16 12:18 ` Stuart
2009-01-16 23:14   ` sjw
2009-01-15 21:24 Martin
     [not found] ` <a8ef6226-db87-4c4c-b38e-9dbc77374f4c@t11g2000yqg.googlegroups.com>
2009-01-16  0:45   ` tmoran
2009-01-16  8:02   ` Martin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox