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,FREEMAIL_FROM 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!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 31 Jan 2005 21:13:08 -0600 From: "Steve" Newsgroups: comp.lang.ada References: <1107182585.066205.21490@f14g2000cwb.googlegroups.com> Subject: Re: Printing out an Array Date: Mon, 31 Jan 2005 19:14:47 -0800 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: NNTP-Posting-Host: 24.22.63.157 X-Trace: sv3-SoYwRSrtzrggISlyQqKKkdEyVILAgAdXcgU5e7/abwqBPk0x/1WAffKPppAYbqBZL4OtDpAvg6rxWXm!iDxfDGgCKnQN6xsFOVq6hjAOeUP6yc63EpcxYSW23OkWKm2xDpgSalaD3NeU X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.22 Xref: g2news1.google.com comp.lang.ada:8097 Date: 2005-01-31T19:14:47-08:00 List-Id: Since the function Octet_Vers_Bits returns an array of Tab_Bits, no need to call it inside the loop. ... T1 := Octet_Vers_Bits(X); for I in 0 .. 7 loop Put(T1(I),1); end loop; Just index the array to get the value. Also, I prefer: Resultat(I) := N mod 2; To: if ( N mod 2 = 1 ) then Resultat(I) := 1; else Resultat(I) := 0; end if; But you will find other programmers who prefer the second form. Steve (The Duck) wrote in message news:1107182585.066205.21490@f14g2000cwb.googlegroups.com... > 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 > ---------------------------------------------------------- > with Ada.Text_Io; use Ada.Text_Io; > with Ada.Integer_text_Io; use Ada.Integer_text_Io; > > procedure Pas3 is > > subtype Octet is Integer range 0..255; > subtype Bit is Integer range 0..1; > type Tab_Bits is array (0 .. 7) of Bit; > > function Octet_Vers_Bits (Oc : Octet ) > return Tab_Bits is > Resultat : Tab_Bits; > N : Octet; > > begin > N := Oc; > for I in reverse 0..7 loop > if ( N mod 2 = 1 ) then > Resultat(I) := 1; > else > Resultat(I) := 0; > end if; > N := N / 2; > end loop; > return Resultat; > end Octet_Vers_Bits; > > t1 : Tab_bits; > x : integer; > > begin > Put (" donner x: "); > Get(x); > > > for I in 0 .. 7 loop > t1 := Octet_Vers_Bits(x); > Put(Bit(x)); ----------------> here is the problem, what should I > put here. > end loop; > end Pas3 ; >