MediaWiki:Sitenotice:
2024-03-02: The wiki ran out of disk space, so things were not working. This has been resolved by adding another 5GB of quota ;-) Thanks to Tim Lindner for reporting the issues.
2020-05-17: If a page gives you an error about some revision not being found, just EDIT the page and the old page should appear in the editor. If it does, just SAVE that and the page should be restored. OS-9 Al (talk) 12:22, 17 May 2020 (CDT)
DECCONV: Difference between revisions
Jump to navigation
Jump to search
Luis46coco (talk | contribs) mNo edit summary |
(Category) |
||
Line 80: | Line 80: | ||
890 ER$="Y" | 890 ER$="Y" | ||
900 RETURN | 900 RETURN | ||
[[Category:BASIC]] |
Latest revision as of 21:08, 10 September 2015
100 DIM R$(16), T(6,3), T$(6,2) 110 DATA 5, 10,2,DECIMAL,BINARY,16,2,10,BINARY,DECIMAL 120 DATA 5,10,16,DECIMAL,HEXADECIMAL 130 DATA 4,16,10,HEXADECIMAL,DECIMAL,16,2,16,BINARY,HEXADECIM 140 DATA 4,16,2,HEXADECIMAL,BINARY 150 FOR 1=1 TO 6 160 READT(I,1), T(I,2), T(I,3), T$(I,1), T$(I,2): NEXT I 170 CLS: PRIMT@2,"DECIMAL TO BASE X CONVERTER" 180 PRINT@64,"CONVERT FROM:" 190 FOR 1=1 TO 6 200 PRINT@64+(I*32),I;". ";T$(I,1);" TO ";T$(I,2): NEXT I 210 PRINT@288,"WHICH ONE";: INPUT A 220 IF (A>O) AND (A<7) THEN 250 230 PRINT@352,"INVALID SELECTION--TRY AGAIN" 240 FOR I=1 TO 300: NEXT I: GOTO17O 250 PRINT@352,"NUMBER IN ";LEFT$(T$(A,1),3);: INPUT AS 260 L=LEN(A$) 270 IF L<=T(A,1) THEM 310 280 PRINT@448,"INVALID ";LEFT$(T$(A,1),3);" NUMBER--TRY AGAIN" 290 FOR I=1 TO 300: NEXT I 300 PRINT@448."";:PRINT:PRINT@367,"": GOTO25O 310 ON A GOSUB38O,72O,38O,720,720,720 320 IF ER$="Y" THEN ER$="": GOTO28O 330 PRINT@416,"EMTER R FOR RESTART, OR JUST" 340 PRINT@448,"<ENTER> FOR SAME";: INPUT AS 350 IF A$="R" THEN 170 360 IF A$="" THEN PRINT@416,":PRINT@448,":PRINT@367,":PRINT 370 G0T0330 380 REM DECIMAL SUBROUTINE 390 FOR I=1 TO L 400 N$=MID$(A$,I,1) 410 IF NOT (N$>-"O" AND N$<="9") THEN 460 420 NEXT I 430 N1=VAL(A$) 440 IF N1>65535 THEN 460 450 GOSUB48O: GOTO47O 460 ER$="Y" 470 RETURN 480 REM CONVERT DEC TO BIN/HEX SUBROUTINE 490 FOR I=1 TO 16 500 R$(I)=": NEXT I 510 FOR I=16 TO 1 STEP -1 520 N2=INT(N1/T(A,3)) 530 R$(I)=STR$(N1_(T(A,3)*N2)) 540 IF N2=O THEN 560 550 N1=N2: NEXT I 560 L=I 570 REM PRINT DEC TO BIN/HEX 580 PRINT@384,"NUMBER IN ";LEFT$(T$(A,2),3);" "; 590 P=398 600 FOR I=L TO 16 610 N2=LEN(R$(I)) 620 N$=MID$(R$(I) ,2,N2) 630 IF N$="10" THEN N$="A" 640 IF N$="11" THEN N$="B" 650 IF N$="12" THEN N$="C" 660 IF N$="13" THEN N$="D" 670 IF N$="14" THEN N$="E" 680 IF N$="15" THEN N$="F" 690 P=P+1: PRINT@P,N$; 700 NEXT I 710 RETURN 720 REM BIN/HEX SUBROUTINE 730 N1=0: N2=0 740 FOR I=1 TO L 750 N$=MID$(A$,I,1) 760 IF (N$="0") OR (N$="L") THEN 820 770 IF NOT (A=4 OR A=6) THEN 890 780 IF (N$>="2") AND (N$<="9") THEN 820 790 N3=ASC(N$)-55 800 IF (N3<=15) THEN 830 810 GOTO890 820 N3=VAL(N$) 830 N2=N1 840 N1=(N2*T(A,2))+N3 850 NEXT I 860 IF (A=5) OR (A=6) THEN COSUB480: GOTO900 870 PRINT@384,"NUMBER IN ";LEFT$(T$(A,2),3);" ";N1 880 GOTO900 890 ER$="Y" 900 RETURN