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 ;
Up spake ········@mac.com:
> Hello all, I'm new to this and comming from Java environment. I have
> this code to convert bytes to bits.
>
> function Octet_Vers_Bits (Oc : Octet )
> return Tab_Bits is
> Resultat : Tab_Bits;
> N : Octet;
> [...]
That's not Java or Lisp; it looks like a Wirth language to me.
This group is about the family of computer languages called "Lisp".
In what way is your question relevant to this forum?
--
-trent
Make backups before you try something new or interesting or experimental
or radical or if the day has a "y" in it. -- Chris Hacking
Trent Buck <·········@tznvy.pbz> writes:
> Up spake ········@mac.com:
> > Hello all, I'm new to this and comming from Java environment. I have
> > this code to convert bytes to bits.
> >
> > function Octet_Vers_Bits (Oc : Octet )
> > return Tab_Bits is
> > Resultat : Tab_Bits;
> > N : Octet;
> > [...]
>
> That's not Java or Lisp; it looks like a Wirth language to me.
You're cutting too much:
> > with Ada.Text_Io; use Ada.Text_Io;
> > with Ada.Integer_text_Io; use Ada.Integer_text_Io;
Even if you did not know Ada, you could infer from the input data that
it's Ada. Eg, not Niklaus Wirth, but Jean Ichbiah.
http://en.wikipedia.org/wiki/Ada_programming_language
--
__Pascal Bourguignon__ http://www.informatimago.com/
Kitty like plastic.
Confuses for litter box.
Don't leave tarp around.