comp.lang.ada
 help / color / mirror / Atom feed
* Newbie question : types , representation
@ 1999-08-22  0:00 Jos De Laender
  1999-08-22  0:00 ` Wilhelm Spickermann
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Jos De Laender @ 1999-08-22  0:00 UTC (permalink / raw)


Hi,

I'm trying to learn ADA on my own. 

My background is C programming (sorry ;-) ) and VHDL hardware
programming. The latter helps a lot , as VHDL inherited a lot of ADA.

I'm having trouble with following very simple problem , at least in
doing it portable and clean.

In base64 decoding , each ASCII character must be translated to 6 'bit'.
4 characters translate then to 3 bytes. The problem and algorithms are
trivial. In C I could do it within 5 minutes.

It would involve some bitmanipulation (shifting , anding , oring ) on
the character itself and then outputting. That's it.

However, what's unclear is how to do this in ADA types : A character
cannot be bit manipulated , and so needs some explicit translation to a
'byte' or something.
How is this usually done ? I would guess to use a modular type 2**8 ? If
I declare such a type , and I want a byte , is this guaranteed by 2**8
or do I have explicitly  to attribute it with a 'for Byte'size use 8' ?
Also I will need some kind of assignment to that modular type, say aVar
:= 2#00000011#. This will assign the value 3 to aVar ? Is this
guaranteed to have that bit pattern ? Or could I imagine a (probably
exotic) machine on which 3 is represented with another bit pattern ?
Does ADA guarantee ?
If I output aVar with a write function , is the bitpattern guaranteed ?

Thanks for all clarifications.

Jos




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

end of thread, other threads:[~1999-08-27  0:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-22  0:00 Newbie question : types , representation Jos De Laender
1999-08-22  0:00 ` Wilhelm Spickermann
1999-08-23  0:00   ` Simon Wright
1999-08-23  0:00   ` Martin C. Carlisle
1999-08-22  0:00 ` Martin Dowie
1999-08-22  0:00 ` Robert Dewar
1999-08-23  0:00   ` Wolfgang Jeltsch
1999-08-24  0:00     ` tmoran
1999-08-24  0:00   ` jdla
1999-08-24  0:00     ` Matthew Heaney
1999-08-24  0:00       ` Jos De Laender
1999-08-24  0:00         ` Brian Rogoff
1999-08-25  0:00           ` Jos De Laender
     [not found] ` <37C621F3.C6C0DC3A@acenet.com.au>
1999-08-27  0:00   ` tmoran
1999-08-27  0:00     ` Florian Weimer
1999-08-27  0:00   ` David C. Hoos, Sr.

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