10 ! ----- OCT_TO_DEC.FUN ----- ! ! ----- OCTAL TO DECIMAL CONVERSION ROUTINE ----- ! ! ----- Last Change 05/01/89 by Brian Lomasky ----- ! ! ----- Teradyne, Inc., 179 Lincoln Street, Boston, MA 02111 ----- ! ----- (617) 482-2706, x3259 ----- ! ! ----- Neither Brian Lomasky nor Teradyne, Inc. implicitly or ----- ! ----- explicitly implies this program is usable in any way. ----- ! ----- This program is released to the public domain in an ----- ! ----- "AS-IS" condition. ----- ! ! ----- Restrictions: ----- ! ----- 1) Requires VAX BASIC V2.4 or later. ----- ! FUNCTION LONG OCT_TO_DEC(LONG OCTAL_VALUE) OPTION TYPE = EXPLICIT DECLARE LONG DEC_OUTPUT ! DECIMAL OUTPUT DECLARE LONG OCT_DIV ! OCTAL DIVISOR DECLARE LONG OCT_INPUT ! OCTAL INPUT DECLARE LONG TEMP ! TEMPORARY WORD DEC_OUTPUT = 0% OCT_INPUT = OCTAL_VALUE FOR TEMP = 7% TO 0% STEP -1% OCT_DIV = INT(OCT_INPUT / 8^TEMP) IF OCT_DIV > 0% THEN DEC_OUTPUT = DEC_OUTPUT + 10^TEMP * OCT_DIV OCT_INPUT = OCT_INPUT - 8^TEMP * OCT_DIV END IF NEXT TEMP OCT_TO_DEC = DEC_OUTPUT END FUNCTION