From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7844279822ce7c28,start X-Google-Attributes: gid103376,public From: Jos De Laender Subject: Newbie question : types , representation Date: 1999/08/22 Message-ID: <37BFC251.601ADF8F@village.uunet.be>#1/1 X-Deja-AN: 515749359 Content-Transfer-Encoding: 7bit Organization: UUNET Benelux (post does not reflect views of UUNET Benelux) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-22T00:00:00+00:00 List-Id: 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