Decode Floating Point Value 2
This program works with BASICS I-IV and decodes or encodes a Floating-Point variable (or the Floating Point Work Area - FWA) between a Numeric Decimal value and the Internal BASIC representation.
You can choose to (1) enter the Exponent and Mantissa values in Hexadecimal format and the program will return the numeric decimal value or (2) enter the numeric decimal value and have the program return the Internal BASIC representation of that value.
10 REM FLOATING POINT VARIABLE-DECIMAL 20 Z=0 30 PRINT'' 40 INPUT"1) VARIABLE TO DECIMAL"'"2) DECIMAL TO VARIABLE"'"3) FWA TO DECIMAL"';A$ 45 IF A$="3" GOTO 200 50 IF A$="2" INPUT''"Enter value ";Z 60 IF A$="2" I%=3+?&4B4+256*?&4B5: PRINT'"Varable is:"'"Exponent : ";~?I%'"Mantissa1 : ";~?(I%+1)'"Mantissa2 : ";~?(I%+2)'"Mantissa3 : ";~?(I%+3)'"Mantissa4 : ";~?(I%+4)' 65 ONERROROFF 70 IF A$="1" INPUT''"Enter Exponent &"B$:B%=EVAL("&"+B$) 75 ONERRORGOTO70 80 IF A$="1" INPUT"Enter Mantissa1 &"B$:C%=EVAL("&"+B$) 85 ONERRORGOTO80 90 IF A$="1" INPUT"Enter Mantissa2 &"B$:D%=EVAL("&"+B$) 95 ONERRORGOTO90 100 IF A$="1" INPUT"Enter Mantissa3 &"B$:E%=EVAL("&"+B$) 105 ONERRORGOTO100 110 IF A$="1" INPUT"Enter Mantissa4 &"B$:F%=EVAL("&"+B$) 120 IF A$="1" I%=3+?&4B4+256*?&4B5:?I%=B%:?(I%+1)=C%:?(I%+2)=D%:?(I%+3)=E%:?(I%+4)=F%:PRINT'"The decimal is : ";Z 130 RUN 140 INPUTA 150 ?&402 = 2: PRINT"Fixed=";A 160 ?&402 = 1: PRINT"Scientific=";A 170 ?&402 = 0: PRINT"General=";A 180 END 200 REM FWA TO DECIMAL 210 INPUT''"Enter Exponent &"B$:B%=EVAL("&"+B$) 215 ONERRORGOTO210 220 INPUT"Enter Mantissa1 &"B$:C%=EVAL("&"+B$) 225 ONERRORGOTO220 230 INPUT"Enter Mantissa2 &"B$:D%=EVAL("&"+B$) 235 ONERRORGOTO230 240 INPUT"Enter Mantissa3 &"B$:E%=EVAL("&"+B$) 245 ONERRORGOTO240 250 INPUT"Enter Mantissa4 &"B$:F%=EVAL("&"+B$) 260 I%=3+?&4B4+256*?&4B5:?I%=B%:?(I%+1)=C%:?(I%+2)=D%:?(I%+3)=E%:?(I%+4)=F% 270 X=ABS(Z) 280 IF C%>0 ANDC%<&80 THEN I%=3+?&4B4+256*?&4B5:?I%=B%:?(I%+1)=&80:?(I%+2)=0:?(I%+3)=0:?(I%+4)=0:X=Z+X 290 PRINT'"The decimal is : ";X 400 RUN