Subject: | |
From: | |
Reply To: | |
Date: | Mon, 4 Dec 2000 09:30:31 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
At 11:03 AM -0400 12/4/00, Bob Comeau wrote:
>An expansion the simply elegant procedure easily displays the
>representation in the base chosen, up to 36:
...
>setvar base_rep ""
>setvar base_digits "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
...
> if !base < 37
> setvar base_rep "![str(base_digits,mod_val+1,1)]"+base_rep
> endif
...
>if !base < 37
> echo Written as !base_rep in base !base
>endif
Thanks Bob, that's a very nice addition to the script.
When I first wrote it and saw results like
:powersum 4095,16,detail
4095 = (15*1)+(15*16)+(15*256)
I thought, "hmmm, we almost have a base conversion utility here...", but I
didn't take it to the next step and actually implement it. I'm glad you did.
If we can tolerate a little potential confusion between upper and lower
case letters, then we could extend this a little further:
setvar base_digits &
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
...
if !base < len(base_digits)+1
setvar...
Then we could do something like
:powersum 8579781,62,detail
8579781 = (35*1)+(61*62)+(61*3844)+(35*238328)
Written as ZzzZ in base 62
Cheers,
Barry Lake [log in to unmask]
Allegro Consultants, Inc. www.bogus.allegro.com
(408)252-2330
--------
Attempting to reduce spam influx.
Remove ".bogus" to create valid address.
|
|
|