Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If you can't understand it, it is intuitively obvious.


devel / comp.lang.ada / Re: Integer_IO or Modular_IO with different base as default

SubjectAuthor
* Integer_IO or Modular_IO with different base as defaultKen Roberts
+* Re: Integer_IO or Modular_IO with different base as defaultSimon Wright
|`* Re: Integer_IO or Modular_IO with different base as defaultKen Roberts
| `* Re: Integer_IO or Modular_IO with different base as defaultJeffrey R.Carter
|  `- Re: Integer_IO or Modular_IO with different base as defaultKen Roberts
`- Re: Integer_IO or Modular_IO with different base as defaultBen Bacarisse

1
Integer_IO or Modular_IO with different base as default

<49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6293&group=comp.lang.ada#6293

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:27c3:: with SMTP id i3mr1908173qkp.442.1637011621902;
Mon, 15 Nov 2021 13:27:01 -0800 (PST)
X-Received: by 2002:a25:284:: with SMTP id 126mr2304549ybc.486.1637011621704;
Mon, 15 Nov 2021 13:27:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 15 Nov 2021 13:27:01 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=47.34.247.166; posting-account=o_Y23woAAACPYGlDsFV1OivhygPNSoRn
NNTP-Posting-Host: 47.34.247.166
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>
Subject: Integer_IO or Modular_IO with different base as default
From: alisonk...@gmail.com (Ken Roberts)
Injection-Date: Mon, 15 Nov 2021 21:27:01 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Ken Roberts - Mon, 15 Nov 2021 21:27 UTC

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.

Does anyone have an idea on how to instantiate Integer_IO (or Modular_IO) with Default_Base := 8 ?

So far, the only thing I've been able to work with is copy Ada.Text_IO.Integer_IO (or Modular_IO) in my project as a different package with the only change being the Default_Base parameter.

Any help with noob questions would be appreciated.

Re: Integer_IO or Modular_IO with different base as default

<lylf1pnlm9.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6294&group=comp.lang.ada#6294

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!8nKyDL3nVTTIdBB8axZhRA.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Integer_IO or Modular_IO with different base as default
Date: Mon, 15 Nov 2021 21:40:30 +0000
Organization: Aioe.org NNTP Server
Message-ID: <lylf1pnlm9.fsf@pushface.org>
References: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="47723"; posting-host="8nKyDL3nVTTIdBB8axZhRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:0Hxe3QDFlDTHhxnSj6uCHsCK9vA=
 by: Simon Wright - Mon, 15 Nov 2021 21:40 UTC

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#

Re: Integer_IO or Modular_IO with different base as default

<09d82d22-aca1-4ff9-9e2a-33a180544f88n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6295&group=comp.lang.ada#6295

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:291:: with SMTP id z17mr2578878qtw.138.1637014188866;
Mon, 15 Nov 2021 14:09:48 -0800 (PST)
X-Received: by 2002:a5b:846:: with SMTP id v6mr2479636ybq.457.1637014188615;
Mon, 15 Nov 2021 14:09:48 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 15 Nov 2021 14:09:48 -0800 (PST)
In-Reply-To: <lylf1pnlm9.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=47.34.247.166; posting-account=o_Y23woAAACPYGlDsFV1OivhygPNSoRn
NNTP-Posting-Host: 47.34.247.166
References: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com> <lylf1pnlm9.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <09d82d22-aca1-4ff9-9e2a-33a180544f88n@googlegroups.com>
Subject: Re: Integer_IO or Modular_IO with different base as default
From: alisonk...@gmail.com (Ken Roberts)
Injection-Date: Mon, 15 Nov 2021 22:09:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: Ken Roberts - Mon, 15 Nov 2021 22:09 UTC

On Monday, November 15, 2021 at 1:40:34 PM UTC-8, Simon Wright wrote:
< snip >
I was going to add before your reply that I'm trying to get output without the extra padding of showing the base.

I would rather not have to send the output to a subroutine that would strip the extra characters out or write a new routine to convert the decimal to octal before printing.

It's more in keeping with the system design of the original digital equipment as well as the documentation that

As an example, the format as documented for the equipment:

Data word: DDDDD DDDDD (30-bit word in octal data format)
Instruction word: FF J K B DDDDD (30-bit word in octal instruction 1 format)
Instruction word: FF JJ K B DDDDD (30-bit word in octal instruction 2 format)

All of the documentation is written in those formats, and having 8X..X surrounding each field really sucks on the output when trying to evaluate between original documentation and the program output.

Re: Integer_IO or Modular_IO with different base as default

<87tugdnk3b.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6296&group=comp.lang.ada#6296

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: Integer_IO or Modular_IO with different base as default
Date: Mon, 15 Nov 2021 22:13:28 +0000
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <87tugdnk3b.fsf@bsb.me.uk>
References: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="5fe867269cb9ac96facdd1dae680befb";
logging-data="30792"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WpDrKDhvymdlvLggGcH1UnmL8h8dndoU="
Cancel-Lock: sha1:XRrfcdVhviLdJUBq2mPZB1xqkhY=
sha1:j+47bw9lfE2zpXjOm+I6ExI+h3o=
X-BSB-Auth: 1.bfdbf931ebe71224d9ed.20211115221328GMT.87tugdnk3b.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 15 Nov 2021 22:13 UTC

Ken Roberts <alisonken1@gmail.com> writes:

> Does anyone have an idea on how to instantiate Integer_IO (or
> Modular_IO) with Default_Base := 8 ?

Instantiate Integer_IO and then assign Default_Base := 8:

with Ada.Text_IO; use Ada.Text_IO;
procedure Oct is
package Oct_IO is new Integer_IO(Integer);
begin
Oct_IO.Default_Base := 8;
Oct_IO.Put(16);
end Oct;

(Add "use Oct_IO;" if you prefer.)

I don't think there is a way to do this on instantiation so that
Default_Base is 8 and can't be changed, which would be nice. (Note: my
Ada is /very/ rusty. Take /anyone's/ answer over mine about this!)

--
Ben.

Re: Integer_IO or Modular_IO with different base as default

<smupcf$nk6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6297&group=comp.lang.ada#6297

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Integer_IO or Modular_IO with different base as default
Date: Tue, 16 Nov 2021 00:10:05 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <smupcf$nk6$1@dont-email.me>
References: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>
<lylf1pnlm9.fsf@pushface.org>
<09d82d22-aca1-4ff9-9e2a-33a180544f88n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Nov 2021 23:10:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2ca2cb45ceb0506a2c4aa9dcb9a1f6f5";
logging-data="24198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pgQxS4GvldBQhYmYxlT5tQd9pBPtf2so="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
Cancel-Lock: sha1:smw3csfa6TI03eEVMjQtXvsn2Bk=
In-Reply-To: <09d82d22-aca1-4ff9-9e2a-33a180544f88n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Mon, 15 Nov 2021 23:10 UTC

On 2021-11-15 23:09, Ken Roberts wrote:
> I was going to add before your reply that I'm trying to get output without the extra padding of showing the base.

Ada.Text_IO.Integer_IO and Ada.Text_IO.Modular_IO both declare

Default_Base : Number_Base := 10;

This is a variable, so you can change it.

However, that outputs in based-literal format.

You can use PragmARC.Images (https://github.com/jrcarter/PragmARC) to
obtain images in any base without the base information. Image width and
zero filling are also provided.

--
Jeff Carter
"I spun around, and there I was, face to face with a
six-year-old kid. Well, I just threw my guns down and
walked away. Little bastard shot me in the ass."
Blazing Saddles
40

Re: Integer_IO or Modular_IO with different base as default

<45dac231-22fa-409e-97a4-238d16fe832dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6304&group=comp.lang.ada#6304

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1294:: with SMTP id w20mr25724984qki.197.1637280402830;
Thu, 18 Nov 2021 16:06:42 -0800 (PST)
X-Received: by 2002:a25:3787:: with SMTP id e129mr30574382yba.91.1637280402535;
Thu, 18 Nov 2021 16:06:42 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 18 Nov 2021 16:06:42 -0800 (PST)
In-Reply-To: <smupcf$nk6$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=47.34.247.166; posting-account=o_Y23woAAACPYGlDsFV1OivhygPNSoRn
NNTP-Posting-Host: 47.34.247.166
References: <49db08e4-4380-4877-9e50-a986856c9821n@googlegroups.com>
<lylf1pnlm9.fsf@pushface.org> <09d82d22-aca1-4ff9-9e2a-33a180544f88n@googlegroups.com>
<smupcf$nk6$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45dac231-22fa-409e-97a4-238d16fe832dn@googlegroups.com>
Subject: Re: Integer_IO or Modular_IO with different base as default
From: alisonk...@gmail.com (Ken Roberts)
Injection-Date: Fri, 19 Nov 2021 00:06:42 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: Ken Roberts - Fri, 19 Nov 2021 00:06 UTC

Sorry for the delay in getting back - $DAYJOB and $ILLNESS combined.

On Mon, Nov 15, 2021 at 3:10 PM Jeffrey R.Carter <deleted> wrote:
On 2021-11-15 23:09, Ken Roberts wrote:
> I was going to add before your reply that I'm trying to get output without the extra padding of showing the base.

Ada.Text_IO.Integer_IO and Ada.Text_IO.Modular_IO both declare

Default_Base : Number_Base := 10;

This is a variable, so you can change it.

However, that outputs in based-literal format.

You can use PragmARC.Images (https://github.com/jrcarter/PragmARC) to
obtain images in any base without the base information. Image width and
zero filling are also provided.

--
Jeff Carter

Hmmm. After testing by setting the base manually after instantiation, still adds the based-literal information as noted.

So, it's either copy Modular_IO into my project (with renaming) and change the default base, or add another package to monitor for updates.

Fun either way.

Thanks for the help both Jeff and Ben. (Sincerely, not ironically).

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor