DECLARE SUB SUBGAIN () DECLARE SUB SUBDB () CLS 10 INPUT "Enter d to convert gain to db. Enter g to convert db into gain. ", s$ PRINT " " IF s$ = "g" THEN CALL SUBGAIN IF s$ = "d" THEN CALL SUBDB PRINT " " GOTO 10 SUB SUBDB PRINT "THIS CONVERTS GAIN INTO DECIBELS" INPUT "Enter p if you are using power gain ( 10 * LOG (gain) ): "; p$ 200 INPUT "Enter the gain: "; g IF g < 0 THEN PRINT "negative not defined" GOTO 200 END IF IF g < 1D-41 THEN PRINT "gain too small to calculate. Zero gain is negative infinity db." PRINT " note: (gain a) * (gain b) converts to (gain a in db) + (gain b in db)" GOTO 200 END IF IF g > 1D+36 THEN PRINT "gain too large to calculate" PRINT " note: (gain a) * (gain b) converts to (gain a in db) + (gain b in db)" GOTO 200 END IF a = 20 IF p$ = "p" THEN a = 10 DB = a * (LOG(g) / LOG(10)) REM here LOG is natural log (base e). To convert to base 10, divide by natural log of 10. PRINT DB, " decibels" END SUB SUB SUBGAIN PRINT "THIS CONVERTS DECIBELS INTO GAIN." INPUT "Enter p if you are using power gain ( 10 * LOG (gain) ): "; p$ INPUT "Enter the number of decibels. ", d a = 20 IF p$ = "p" THEN a = 10 GAIN = EXP((d / a) * LOG(10)) REM gain = 10^(d/a) would also work but I wanted to use natural log as an exercise PRINT "GAIN = "; GAIN END SUB