******************************************************************************** * * Support of subroutine '-DIVH' * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intended * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description......................................... * 10/14/98 23801 SAP Change copyrights. * 06/26/96 18703 KAM Integrate subroutine into universe ******************************************************************************* $OPTIONS DEFAULT subroutine DIVH(ans,NUMER,DENOM) * REV: 06/05/96 * * for DENOMinator values and sub-values, replace '' & non-numerics w/0 * FIXED.DENOM='' DLM.TYP=255 LOOP UNTIL DLM.TYP=0 DO REMOVE TEMP FROM DENOM SETTING DLM.TYP IF NOT(NUM(TEMP)) THEN TEMP=0 ELSE TEMP+=0 FIXED.DENOM:=TEMP IF DLM.TYP > 0 THEN FIXED.DENOM:=CHAR(256-DLM.TYP) REPEAT * * build a boolean matching the structure of DENOM where * the value is TRUE if the adjusted denominator is not 0 * BOOL.DENOM0=NES(FIXED.DENOM,REUSE(0)) * * for every place in the denominator where there is a zero, * make the matching position of the numerator zero * NUMER.ZERO=MULS(NUMER,REUSE(BOOL.DENOM0)) * * in the 'fixed' denominator, set every zero value to one and * leave all non-zero values alone * FIXED.DENOM=ADDS(FIXED.DENOM,NOTS(BOOL.DENOM0)) * * at this point, the numerator values that correspond to zeroes in the * 'fixed' denominator are now zero and the 'fixed' denominator has * ones in those positions. This way 0 (numerator) divided by * 1 (denominator) = 0, without the Divide by Zero message. All other * numbers in both the numerator and divisor are okay and division will * work as expected. * ans=DIVS(NUMER.ZERO,REUSE(FIXED.DENOM)) return