From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16538 invoked from network); 19 Feb 1998 07:00:55 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 19 Feb 1998 07:00:55 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id BAA05431; Thu, 19 Feb 1998 01:41:22 -0500 (EST) Resent-Date: Thu, 19 Feb 1998 01:41:07 -0500 (EST) Date: Thu, 19 Feb 1998 09:43:47 +0300 (MSK) From: Andrej Borsenkow X-Sender: bor@itsrm1 Reply-To: borsenkow.msk@sni.de To: mito@m2.sprynet.com cc: zsh-users@math.gatech.edu Subject: Re: converting ints from base 10 to base x In-Reply-To: <19980218153921.43255@retriever> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Resent-Message-ID: <"WK1vI1.0.JK1.2Gzwq"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1327 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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@sni.de -------------------------------------------------------------------------