comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Integer_IO or Modular_IO with different base as default
Date: Mon, 15 Nov 2021 21:40:30 +0000	[thread overview]
Message-ID: <lylf1pnlm9.fsf@pushface.org> (raw)
In-Reply-To: 49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com

Ken Roberts <alisonken1@gmail.com> writes:

> I've been trying to look at how to instantiate Ada.Text_IO.Integer_IO
> and Ada.Text_IO.Modular_IO with a different base as default (base 8
> for a project I'm playing with while learning).
>
> So far, the only thing I can find is instantiate with a different
> integer (or mod number), but the base is always defined as 10.
>
> I'd like to output numbers for the project in base 8 (octal) in
> keeping with the documentation on how the digital system works.

You can't change Default_Base, but you can specify the base in which to
output the number, as in ARM A.10.8(11):

   procedure Put(File  : in File_Type;
                 Item  : in Num;
                 Width : in Field := Default_Width;
                 Base  : in Number_Base := Default_Base);

   procedure Put(Item  : in Num;
                 Width : in Field := Default_Width;
                 Base  : in Number_Base := Default_Base);

e.g.

   Put (10, Base => 8);

outputs

   8#12#

  reply	other threads:[~2021-11-15 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 21:27 Integer_IO or Modular_IO with different base as default Ken Roberts
2021-11-15 21:40 ` Simon Wright [this message]
2021-11-15 22:09   ` Ken Roberts
2021-11-15 23:10     ` Jeffrey R.Carter
2021-11-19  0:06       ` Ken Roberts
2021-11-15 22:13 ` Ben Bacarisse
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox