[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dc hex/dec conversion
From: |
Neal H. Walfield |
Subject: |
Re: dc hex/dec conversion |
Date: |
04 Nov 2002 20:50:54 -0500 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 |
> I casually found this method to convert big numbers to/from dec/hex giving
> "mod" as operator, although I coundn't find it documented in the dc man
> page, version "Last change: 1997-03-25" of my Solaris 8 system:
>
> $ dc
> >2673633572206487918868565023022626 -hex-
> >16
> >mod
> 155 is unimplemented
> >p
> 83D200000006B30D0387A5745E22 -dec-
> >10
> >mod
> 155 is unimplemented
> >p
> 2673633572206487918868565023022626 -again hex-
>
> I wonder what the message "155 is unimplemented" means and if "mod" is
> expected to produce this result; the fact is, it works.
You are at best lucky. What you are really doing is the running the
commands `m', `o' and `d': the first generates the message you are
seeing; the second pops the stacks and changes the output base to it
(in your case, 16 and then 10); and `d' does a pop, push, push which
is the number you want to convert and, in your example, is useless but
harmless. Finally, you call `p' which prints the top of the stack in
the current output base.
Which is to say, there is no `mod' operator.
- dc hex/dec conversion, Juan-Carlos . ManzanoAndres, 2002/11/04
- Re: dc hex/dec conversion,
Neal H. Walfield <=