求救下面一段程序的算法是什么,我看不懂呀。 PROCEDURE DecToBin
PARAMETER INNUM
OUTSTR = SPACE(0)
DO WHILE INNUM > 0
OUTSTR = STR(MOD(INNUM,2),1,0) + OUTSTR
INNUM = INT(INNUM / 2)
ENDDO
RETURN (OUTSTR)
ENDPROC
*------
PROCEDURE BinToDec
PARAMETER INSTR
PRIVATE ALL LIKE j*
JNLEN = LEN(ALLTRIM(INSTR))
JNSUM = 0
FOR NCTR = 0 TO JNLEN
IF SUBSTR(INSTR,JNLEN - NCTR,1) = '1'
JNSUM = JNSUM + (2 ** NCTR)
ENDIF
ENDFOR
RETURN (JNSUM)
ENDPROC
*------
PROCEDURE DecToHex
PARAMETER INNUM
OUTSTR = SPACE(0)
DO WHILE INNUM > 0
OUTSTR = FINDHEX(MOD(INNUM,16)) + OUTSTR
INNUM = INT(INNUM / 16)
ENDDO
RETURN (OUTSTR)
ENDPROC
*------
PROCEDURE FindHex
PARAMETER INVAL
PRIVATE ALL LIKE j*
DO CASE
CASE INVAL = 10
JOUTSTR = 'A'
CASE INVAL = 11
JOUTSTR = 'B'
CASE INVAL = 12
JOUTSTR = 'C'
CASE INVAL = 13
JOUTSTR = 'D'
CASE INVAL = 14
JOUTSTR = 'E'
CASE INVAL = 15
JOUTSTR = 'F'
OTHERWISE
JOUTSTR = STR(INVAL,1,0)
ENDCASE
RETURN (JOUTSTR)
ENDPROC
*------
PROCEDURE HexToDec
PARAMETER INSTR
PRIVATE ALL LIKE J*
INSTR = ALLTRIM(INSTR)
JLEN = LEN(INSTR)
NSUM = 0
RPTR = 0
FOR NCTR = 1 TO JLEN
CPTR = UPPER(SUBSTR(INSTR,JLEN - RPTR,1))
DO CASE
CASE CPTR = 'A'
CPTR = '10'
CASE CPTR = 'B'
CPTR = '11'
CASE CPTR = 'C'
CPTR = '12'
CASE CPTR = 'D'
CPTR = '13'
CASE CPTR = 'E'
CPTR = '14'
CASE CPTR = 'F'
CPTR = '15'
ENDCASE
NSUM = NSUM + (VAL(CPTR) * 16 ** (NCTR - 1))
RPTR = RPTR + 1
ENDFOR
RETURN (NSUM)
ENDPROC
*------
PROCEDURE fillstr
PARAMETER CCODE1 , INNUM
A1 = '000000000000000000000000'
CCODE1 = ALLTRIM(CCODE1)
A1 = SUBSTR(A1,1,B1)
CCODE1 = A1 + CCODE1
RETURN (CCODE1)
ENDPROC