TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Type: text/plain
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
From: Carlisle Martin C Dr USAFA/DFCS <[log in to unmask]>
Date: Fri, 22 Nov 2002 08:04:19 -0700
MIME-Version: 1.0
Reply-To: Carlisle Martin C Dr USAFA/DFCS <[log in to unmask]>
Parts/Attachments: text/plain (47 lines)
The reason for this is that a byte is the smallest addressable amount of
memory, so a boolean variable occupies a full-byte.  You can create an array
of 8 booleans that occupies a single byte using pragma Pack.  Try:

pragma Pack(arr_type);

Martin C. Carlisle, PhD
Associate Professor and Advisor-in-Charge
Department of Computer Science
United States Air Force Academy

-----Original Message-----
From: [log in to unmask] [mailto:[log in to unmask]]
Sent: Thursday, November 21, 2002 2:44 AM
To: [log in to unmask]
Subject: doubt

Hello sir,
      i had a small doubt regarding the size occupied by the variable of a
boolean type. x : boolean; begin
      put(boolean'size);  -- it is giving 1 bit
      put(x'size); -- it is returning  8 bits

why is it so?

actuallly i want to type cast a array of boolean type into an integer value.

type arr_type is array(integer range 1..2) of boolean;

function uncheck is new unchecked_conversion(arr_type,integer);

a(1) := TRUE
a(2) := TRUE

when converted, the value i am getting is 257 instead of 3
can u please give me some suggestion regarding this

Thanks & Regards,