TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: LEO TULLY
from: BOB SEWELL
date: 1995-03-30 23:15:00
subject: RIPScrip MegaNums

 Well, here's what Leo Tully said about it...
 LT> I am trying to find an algorithm for MegaNums used in RIPScrip
 LT> commands. I know one of you guys have the source around here
 LT> somewhere. 
    Yep, I got 'em. What's it worth to you? (grin)
 DECLARE FUNCTION htd2dec& (x$)
 DECLARE FUNCTION dec2htd$ (x&)
 FUNCTION htd2dec& (x$)  PUBLIC         'htd = hex-tri-decimal
   'remove any spaces before or after MegaNum string
   x$ = RTRIM$(LTRIM$(x$))
   length% = LEN(x$)
   FOR Loop1% = 1 to length%
       'get one MegaNum at a time from string
       char$ = ucase$(mid$(x$, Loop1%, 1))
       'get the ascii value, subtract 48 to get actual value
       temp% = asc( char$ ) - 48
       'if MegaNum was A-Z, subtract another 7
       if temp% > 9 then temp% = temp% - 7
       'add this value to accumulated value, multiplying by
       'appropriate numerical place holder value (10's, 100's, etc)
       dummy& = dummy& + (temp% * 36 ^ (length% - Loop1%))
    NEXT Lp1%
    htd2dec& = dummy&
 END FUNCTION
 FUNCTION dec2htd$ (x&) PUBLIC
   do
      'divide by 36, get remainder
      remainder& = x& mod 36
      select case remainder&
         case 0 to 9
            'translate into ascii character "0" - "9"
            htd$ = chr$(remainder& + 48) + htd$
         case 10 to 36
            'translate into ascii character "A" - "Z"
            htd$ = chr$(remainder& + 55) + htd$
      end select
      'divide again for the next loop-through
      x& = x& \ 36
   loop while x& > 0
   dec2htd$ = htd$
 END FUNCTION
... "Bother," said Pooh as he reloaded his AK-47.
--- PPoint 1.86
---------------
* Origin: Seven Wells On-Line * Nashville, TN (1:116/3000.12)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.