Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: converting ints from base 10 to base x
- X-seq: zsh-users 1327
- From: Andrej Borsenkow <borsenkow.msk@xxxxxx>
- To: mito@xxxxxxxxxxxxxx
- Subject: Re: converting ints from base 10 to base x
- Date: Thu, 19 Feb 1998 09:43:47 +0300 (MSK)
- Cc: zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <19980218153921.43255@retriever>
- Reply-to: borsenkow.msk@xxxxxx
On Wed, 18 Feb 1998, Louis-David Mitterrand wrote:
> Is it possible to print a number from, say base 10, to base 2? For
> example I want to know how 255 looks in base 2, how do I do that? I know
> how to print any number in base 10 with $[16#ff], but the reverse?
>
% typeset -i 2 base2
% base2=255
% print $base2
2#11111111
I would like to know direct way as well. Probably, additional flag, such
as
${(b2)foo}
where value is printed in base 2 if result is integer value. Nice for
arrays as well.
-------------------------------------------------------------------------
Andrej Borsenkow Fax: +7 (095) 252 01 05
SNI ITS Moscow Tel: +7 (095) 252 13 88
NERV: borsenkow.msk E-Mail: borsenkow.msk@xxxxxx
-------------------------------------------------------------------------
Messages sorted by:
Reverse Date,
Date,
Thread,
Author