Binary digits: Difference between revisions
Content added Content deleted
Line 247: | Line 247: | ||
<lang Ada>with ada.text_io;use ada.text_io; |
<lang Ada>with ada.text_io;use ada.text_io; |
||
procedure binary is |
procedure binary is |
||
-- the digits in base 2 |
|||
⚫ | |||
bit : array (0..1) of string (1..1) := ("0","1"); |
|||
(if n=0 then "0" elsif n=1 then "1" else bin_image (n/2) & bin_image (n mod 2)); |
|||
-- the conversion function itself |
|||
⚫ | |||
-- the values we want to test |
|||
test_values : array (1..3) of Natural := (5,50,9000); |
test_values : array (1..3) of Natural := (5,50,9000); |
||
begin |
begin |
||
for test of test_values loop put_line ("Output for" |
for test of test_values loop put_line ("Output for"&test'img&" is "&bin_image (test)); end loop; |
||
end binary;</lang> |
end binary;</lang> |
||