zsh-users
 help / color / mirror / code / Atom feed
* converting ints from base 10 to base x
@ 1998-02-18 20:39 Louis-David Mitterrand
  1998-02-19  6:43 ` Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: Louis-David Mitterrand @ 1998-02-18 20:39 UTC (permalink / raw)
  To: zsh-users

Sorry to ask such a simple question, but I've been through the whole
documentation without success. 

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?

Thanks.

-- 
                        
Louis-David Mitterrand  
http://www.aparima.com  
mito@aparima.com        
                        


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: converting ints from base 10 to base x
  1998-02-18 20:39 converting ints from base 10 to base x Louis-David Mitterrand
@ 1998-02-19  6:43 ` Andrej Borsenkow
  0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 1998-02-19  6:43 UTC (permalink / raw)
  To: mito; +Cc: zsh-users

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
-------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-02-19  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-18 20:39 converting ints from base 10 to base x Louis-David Mitterrand
1998-02-19  6:43 ` Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).