10 ! ----- DEC_TO_OCT.FUN ----- ! ! ----- DECIMAL TO OCTAL 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 DEC_TO_OCT(LONG DECIMAL_VALUE) OPTION TYPE = EXPLICIT DECLARE LONG DEC_DIV ! DECIMAL DIVISOR DECLARE LONG DEC_INPUT ! DECIMAL INPUT DECLARE LONG OCT_OUTPUT ! OCTAL OUTPUT DECLARE LONG TEMP ! TEMPORARY WORD OCT_OUTPUT = 0% DEC_INPUT = DECIMAL_VALUE FOR TEMP = 7% TO 0% STEP -1% DEC_DIV = INT(DEC_INPUT / 10^TEMP) IF DEC_DIV > 0% THEN OCT_OUTPUT = OCT_OUTPUT + 8^TEMP * DEC_DIV DEC_INPUT = DEC_INPUT - 10^TEMP * DEC_DIV END IF NEXT TEMP DEC_TO_OCT = OCT_OUTPUT END FUNCTION