comp.lang.ada
 help / color / mirror / Atom feed
* Booelan Function and sizeof operator
@ 1996-04-10  0:00 EMANUELE COSTA
  1996-04-10  0:00 ` Robert Dewar
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: EMANUELE COSTA @ 1996-04-10  0:00 UTC (permalink / raw)


Hi everybody,
        I would like to know, if I can find something similar to the C
sizeof operator and  boolean functions on integer  in Ada. If
this is not the case how could I write something equal in Ada?

======================
Emanuele Costa
Pendle College
Lancaster University

costa@unix.lancs.ac.uk
======================




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Booelan Function and sizeof operator
  1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
@ 1996-04-10  0:00 ` Robert Dewar
  1996-04-11  0:00 ` Dale Stanbrough
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1996-04-10  0:00 UTC (permalink / raw)


Emanuele asks

"        I would like to know, if I can find something similar to the C
sizeof operator and  boolean functions on integer  in Ada. If
this is not the case how could I write something equal in Ada?"

sizeof correspond to 'Size in Ada

boolean functions are available on unsigned types, but not on signed
types in Ada (the effect of boolean functions on signed types in C
is implementation defined, and Ada prefers not to introduce this
particular implementation dependency).





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Booelan Function and sizeof operator
  1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
  1996-04-10  0:00 ` Robert Dewar
@ 1996-04-11  0:00 ` Dale Stanbrough
  1996-04-12  0:00 ` David Wheeler
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dale Stanbrough @ 1996-04-11  0:00 UTC (permalink / raw)


"sizeof correspond to 'Size in Ada"


...except of course that sizeof returns size in bytes, 
'size returns size in bits.

(I didn't want a repeat of a message posted here about
2 years ago from a student who was *amazed* that Ada
records could be *8* times larger than an equivalent C
struct :-).


Dale




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Booelan Function and sizeof operator
  1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
  1996-04-10  0:00 ` Robert Dewar
  1996-04-11  0:00 ` Dale Stanbrough
@ 1996-04-12  0:00 ` David Wheeler
  1996-04-13  0:00 ` Samuel Tardieu
  1996-04-15  0:00 ` George Haddad
  4 siblings, 0 replies; 6+ messages in thread
From: David Wheeler @ 1996-04-12  0:00 UTC (permalink / raw)


EMANUELE COSTA (costa@UNIX.LANCS.AC.UK) wrote:
: Hi everybody,
:         I would like to know, if I can find something similar to the C
: sizeof operator and  boolean functions on integer  in Ada. If
: this is not the case how could I write something equal in Ada?


sizeof(int)  ===>   Integer'Size

I'm not sure what you mean by "boolean functions on integer".
If you want to _convert_ a Boolean to Integer, you can use 'Pos:

bool x;                   ==> X : Boolean;
printf("%d", (int) x);        Put(X'Pos);

If you mean "and", "or", etc., you can define a packed array of Booleans
and perform operations on the array.  In Ada 95, you can also use
modular types for "and", "or", etc.


--- David A. Wheeler
Net address: wheeler@ida.org




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Booelan Function and sizeof operator
  1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
                   ` (2 preceding siblings ...)
  1996-04-12  0:00 ` David Wheeler
@ 1996-04-13  0:00 ` Samuel Tardieu
  1996-04-15  0:00 ` George Haddad
  4 siblings, 0 replies; 6+ messages in thread
From: Samuel Tardieu @ 1996-04-13  0:00 UTC (permalink / raw)
  To: David Wheeler

>>>>> "David" == David Wheeler <wheeler@aphrodite.csed.ida.org> writes:

David> sizeof(int) ===> Integer'Size

I think you mean: sizeof(int) ===> Integer'Size/System.Storage_Unit

  Sam
-- 
"La cervelle des petits enfants, ca doit avoir comme un petit gout de noisette"
                                                       Charles Baudelaire




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Booelan Function and sizeof operator
  1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
                   ` (3 preceding siblings ...)
  1996-04-13  0:00 ` Samuel Tardieu
@ 1996-04-15  0:00 ` George Haddad
  4 siblings, 0 replies; 6+ messages in thread
From: George Haddad @ 1996-04-15  0:00 UTC (permalink / raw)


Samuel Tardieu wrote:
>> "David" == David Wheeler <wheeler@aphrodite.csed.ida.org> writes: 
> David> sizeof(int) ===> Integer'Size
> 
> I think you mean: sizeof(int) ===> Integer'Size/System.Storage_Unit

Wouldn't it actually be:   :-)
   sizeof(int) ===> ((Integer'Size - 1)/System.Storage_Unit) + 1;

   (Just to drag things out a little more generally. :-))
-- 
I found these opinions on my doorstep, would you please give them a 
good home?




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1996-04-15  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-10  0:00 Booelan Function and sizeof operator EMANUELE COSTA
1996-04-10  0:00 ` Robert Dewar
1996-04-11  0:00 ` Dale Stanbrough
1996-04-12  0:00 ` David Wheeler
1996-04-13  0:00 ` Samuel Tardieu
1996-04-15  0:00 ` George Haddad

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