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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,36b77e6f303e7a0b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Printing out an Array References: <1107182585.066205.21490@f14g2000cwb.googlegroups.com> In-Reply-To: <1107182585.066205.21490@f14g2000cwb.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 01 Feb 2005 03:05:20 GMT NNTP-Posting-Host: 63.186.34.141 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1107227120 63.186.34.141 (Mon, 31 Jan 2005 19:05:20 PST) NNTP-Posting-Date: Mon, 31 Jan 2005 19:05:20 PST Xref: g2news1.google.com comp.lang.ada:8096 Date: 2005-02-01T03:05:20+00:00 List-Id: conchale@mac.com wrote: > Hello all, I'm new to this and comming from Java environment. I have > this code to convert bytes to bits but I dont know what to put in the > last line of code to get on the screen my converted number. Thanks for > any help Assuming this isn't homework, in the package Ada.Text_IO (ARM A.10.1) you will find the generic packages Integer_IO and Modular_IO (described in more detail in ARM A.10.8). If you look at the Put procedures, you will find the parameter Base. This allows you to specify the number base to represent the number in. If you supply the value 2 for Base, you will get the number output in binary. A typical value from Put with Base => 2 might be " 2#10101010#". If you need to get rid of the leading " 2#" and the trailing '#', you can use the Put that writes to a String and manipulate the result. Alternatively, you can use an Image function from PragmARC.Images, which does it for you. So, in Ada it is not necessary to convert the value to an array of bits (which could be accomplished with Ada.Unchecked_Conversion), nor to output the bits individually. Yet another case where Ada is simpler and more expressive than other languages. The PragmAda Reusable Components are available from http://home.earthlink.net/~jrcarter010/pragmarc.htm -- Jeff Carter "You couldn't catch clap in a brothel, silly English K...niggets." Monty Python & the Holy Grail 19