Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Things equal to nothing else are equal to each other.


devel / comp.unix.shell / Convert decimal to base-n

SubjectAuthor
* Convert decimal to base-nRichard Harnden
+* Re: Convert decimal to base-nJanis Papanagnou
|`* Re: Convert decimal to base-nJanis Papanagnou
| `- Re: Convert decimal to base-nRichard Harnden
`- Re: Convert decimal to base-nRandal L. Schwartz

1
Convert decimal to base-n

<s86o7u$vc0$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3814&group=comp.unix.shell#3814

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.com (Richard Harnden)
Newsgroups: comp.unix.shell
Subject: Convert decimal to base-n
Date: Thu, 20 May 2021 23:35:39 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <s86o7u$vc0$1@dont-email.me>
Reply-To: nospam.harnden@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 May 2021 22:35:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2b109aeffc3a2f08358e5a71f715221f";
logging-data="32128"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9LcXxfPkrRMlEAsUSZ5skzylzIpDgYNI="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.2
Cancel-Lock: sha1:TnA+Juo0xXfTJlRGYk9w7z9CaIY=
Content-Language: en-GB
X-Mozilla-News-Host: news://news.eternal-september.org:119
 by: Richard Harnden - Thu, 20 May 2021 22:35 UTC

Hi,

Is there a way to go from decimal to base-n in ksh?

That is, is there an opposite of:
$ echo $((36#z))
35

Thanks,
Richard

Re: Convert decimal to base-n

<s87k47$r3f$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3818&group=comp.unix.shell#3818

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Convert decimal to base-n
Date: Fri, 21 May 2021 08:31:35 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 21
Message-ID: <s87k47$r3f$1@news-1.m-online.net>
References: <s86o7u$vc0$1@dont-email.me>
NNTP-Posting-Host: 2001:a61:252a:da01:54f3:ac33:b91d:8efb
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1621578695 27759 2001:a61:252a:da01:54f3:ac33:b91d:8efb (21 May 2021 06:31:35 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 21 May 2021 06:31:35 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <s86o7u$vc0$1@dont-email.me>
 by: Janis Papanagnou - Fri, 21 May 2021 06:31 UTC

On 21.05.2021 00:35, Richard Harnden wrote:
> Hi,
>
> Is there a way to go from decimal to base-n in ksh?
>
> That is, is there an opposite of:
> $ echo $((36#z))
> 35

Yes, ksh's printf command supports it:

$ printf "%..36d\n" 35
z

After the two dots the number indicates the base.

Janis

> Thanks,
> Richard

Re: Convert decimal to base-n

<s87kc0$r3j$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3819&group=comp.unix.shell#3819

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Convert decimal to base-n
Date: Fri, 21 May 2021 08:35:44 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 29
Message-ID: <s87kc0$r3j$1@news-1.m-online.net>
References: <s86o7u$vc0$1@dont-email.me> <s87k47$r3f$1@news-1.m-online.net>
NNTP-Posting-Host: 2001:a61:252a:da01:54f3:ac33:b91d:8efb
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1621578944 27763 2001:a61:252a:da01:54f3:ac33:b91d:8efb (21 May 2021 06:35:44 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Fri, 21 May 2021 06:35:44 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <s87k47$r3f$1@news-1.m-online.net>
 by: Janis Papanagnou - Fri, 21 May 2021 06:35 UTC

On 21.05.2021 08:31, Janis Papanagnou wrote:
> On 21.05.2021 00:35, Richard Harnden wrote:
>> Hi,
>>
>> Is there a way to go from decimal to base-n in ksh?
>>
>> That is, is there an opposite of:
>> $ echo $((36#z))
>> 35
>
> Yes, ksh's printf command supports it:
>
> $ printf "%..36d\n" 35
> z
>
> After the two dots the number indicates the base.

$ typeset -i36 a=35 ; echo $a ; echo ${a#36#}
36#z
z

is another option.

> Janis
>
>> Thanks,
>> Richard
>

Re: Convert decimal to base-n

<s87mp6$hud$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3820&group=comp.unix.shell#3820

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.com (Richard Harnden)
Newsgroups: comp.unix.shell
Subject: Re: Convert decimal to base-n
Date: Fri, 21 May 2021 08:16:53 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <s87mp6$hud$1@dont-email.me>
References: <s86o7u$vc0$1@dont-email.me> <s87k47$r3f$1@news-1.m-online.net>
<s87kc0$r3j$1@news-1.m-online.net>
Reply-To: nospam.harnden@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 May 2021 07:16:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2b109aeffc3a2f08358e5a71f715221f";
logging-data="18381"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sGnL1Jhlo1uBznXHUA+1yTM7ILH63cu4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:5Wu6+pYgOLXYlQ3nCHscVCIFZVc=
In-Reply-To: <s87kc0$r3j$1@news-1.m-online.net>
Content-Language: en-GB
 by: Richard Harnden - Fri, 21 May 2021 07:16 UTC

On 21/05/2021 07:35, Janis Papanagnou wrote:
> On 21.05.2021 08:31, Janis Papanagnou wrote:
>> On 21.05.2021 00:35, Richard Harnden wrote:
>>> Hi,
>>>
>>> Is there a way to go from decimal to base-n in ksh?
>>>
>>> That is, is there an opposite of:
>>> $ echo $((36#z))
>>> 35
>>
>> Yes, ksh's printf command supports it:
>>
>> $ printf "%..36d\n" 35
>> z
>>
>> After the two dots the number indicates the base.
>
> $ typeset -i36 a=35 ; echo $a ; echo ${a#36#}
> 36#z
> z
>
> is another option.
>

Perfect, thanks very much.

Re: Convert decimal to base-n

<86sg2f50au.fsf@red.stonehenge.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=3827&group=comp.unix.shell#3827

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
From: mer...@stonehenge.com (Randal L. Schwartz)
Newsgroups: comp.unix.shell
Subject: Re: Convert decimal to base-n
References: <s86o7u$vc0$1@dont-email.me>
x-mayan-date: Long count = 13.0.8.9.13; tzolkin = 9 Ben; haab = 11 Zip
Message-ID: <86sg2f50au.fsf@red.stonehenge.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix)
Cancel-Lock: sha1:rRUiDmvaxS2AwtQFrohTsIKuipI=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 15
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Fri, 21 May 2021 20:03:06 UTC
Date: Fri, 21 May 2021 12:55:37 -0700
X-Received-Bytes: 1401
 by: Randal L. Schwartz - Fri, 21 May 2021 19:55 UTC

>>>>> "Richard" == Richard Harnden <richard.nospam@gmail.com> writes:

Richard> Is there a way to go from decimal to base-n in ksh?

I tried to do this with bc(1), but Linux bc(1) has diverged so
far from BSD (the original) bc(1) that it was like a different
language. :(

{sigh}

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor