Negative base numbers: Difference between revisions

Formatted string spacing on output.
(changed driver output for decoding)
(Formatted string spacing on output.)
Line 275:
with Ada.Text_IO; use Ada.Text_IO;
with Negative_Base_Numbers; use Negative_Base_Numbers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
 
with Ada.Text_IO; use Ada.Text_IO;
with Negative_Base_Numbers; use Negative_Base_Numbers;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
 
Line 283 ⟶ 288:
use long_IO;
 
ns : Unbounded_String := Encode_Negative_Base (N, B);
P : Long_Long_Integer;
Output : String (1 .. 12);
 
begin
Line 292 ⟶ 298:
Put_Line (" = " & To_String (ns));
 
Move
(Source => To_String (ns), Target => Output,
Justify => Ada.Strings.Right);
P := Decode_Negative_Base (ns, B);
Put (To_String(ns)Output & " decoded in base ");
Put (" decoded in base ");
Put (Item => B, Width => 3);
Put (" = ");
Put (Item => P, Width => 1);
New_Line (2);
end driver;
 
Line 305 ⟶ 313:
driver (146, -3);
driver (15, -10);
driver (3605836_058, -62);
end Main;</lang>
{{out}}
<pre>
10 encoded in base -2 = 11110
11110 decoded in base -2 = 10
 
146 encoded in base -3 = 21102
21102 decoded in base -3 = 146
 
15 encoded in base -10 = 195
195 decoded in base -10 = 15
 
36058 encoded in base -62 = Ada
Ada decoded in base -62 = 36058</pre>
 
=={{header|ALGOL 68}}==
82

edits