comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: Unclear error message - please help
Date: Mon, 10 Oct 2005 18:49:24 +0200
Date: 2005-10-10T18:49:24+02:00	[thread overview]
Message-ID: <7584946.OpPvqevNQa@linux1.krischik.com> (raw)
In-Reply-To: sa4ek6uxsbk.fsf@snoopy.microcomaustralia.com.au

Brian May wrote:

>>>>>> "Martin" == Martin Krischik <krischik@users.sourceforge.net> writes:
> 
>     Martin> A "range 0..65535" needs 17 bits and an "is Integer" is
>     Martin> usually 32 bit.
> 
>     Martin> See
> 
>     Martin> http://en.wikibooks.org/wiki/Ada_Programming/Types/range
>     Martin> http://en.wikibooks.org/wiki/Ada_Programming/Types/mod
> 
>     Martin> for more info.
> 
> I read the above links but didn't see why a range 0..65535 requires 17
> bits.

All range types alow for positive and negative values - even when the
subtype is restricted to a positive range - so they need a sign bit.

That means the compiler needs to support:

 X : Sixteen_Bits'Base := - 65535;

Most likely Sixteen_Bits'Base'Size will be 32 bit.

Others pointed out that you can request the data to be packed - which
slipped my mind when I was writing the post - sorry about that. In fact you
can pack a range 1000 .. 1255 into 8 bit if you want to.

So I stand corrected in that you need only need 16 after all.

However data which has been packed need to be unpacked to do anything
usefull with them. Performance depends on how well the compiler will handle
the packing/unpacking.

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



  reply	other threads:[~2005-10-10 16:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-17 21:11 Unclear error message - please help Alfred Hilscher
2005-09-17 21:44 ` Gene
2005-09-17 22:02 ` Ludovic Brenta
2005-09-18  2:32 ` Robert A Duff
2005-10-08 19:39   ` Alfred Hilscher
2005-10-08 20:15     ` Björn Persson
2005-10-09  7:34       ` Martin Krischik
2005-10-08 21:28     ` Dmitry A. Kazakov
2005-10-08 23:58     ` Robert A Duff
2005-10-09  7:29     ` Martin Krischik
2005-10-09 14:24       ` Robert A Duff
2005-10-09 22:02       ` Brian May
2005-10-10 16:49         ` Martin Krischik [this message]
2005-10-10 22:20           ` Brian May
2005-10-11  5:48             ` Martin Dowie
2005-10-11 18:03             ` Martin Krischik
     [not found]         ` <h84lk1tqgofrhgabm8q3sqbb80li6733bh@4ax.com>
2005-10-16  1:10           ` Robert A Duff
replies disabled

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