--- title: "Fractions" type: "article" slug: "fractions" url: "http://localhost/article/fractions/" markdown_url: "http://localhost/article/fractions.md" published_at: "2022-10-07T12:23:02+00:00" modified_at: "2026-07-17T22:02:41+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "It is interesting to see the computer work in true fractions instead of converting everything to decimal numbers. This program first displays a blank equation: 0/0 # 0/0 = ? Each unknown flashes, in turn, for entry of a number operator. Lines 55 to 80 provide the necessary cross-multiplication. The result is available as X…" category: - name: "CATS Newsletter" slug: "cats-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/cats-newsletter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "H. Edward Weppler" slug: "h-e-weppler" taxonomy: "indiv" url: "http://localhost/indiv/h-e-weppler/" publication_r: id: 35941 title: "CATS Newsletter" type: "periodical" url: "http://localhost/periodical/cats-newsletter/" authors: "H. E. Weppler" authors_r: - name: "H. Edward Weppler" slug: "h-e-weppler" taxonomy: "indiv" url: "http://localhost/indiv/h-e-weppler/" volume: "6" issue: "1" issues_articles: - id: 39632 title: "CATS v6 n1" type: "issue" url: "http://localhost/issue/cats-v6-n1/" pages: "6" pubdate: "May 1988" archive_link: false --- # Fractions It is interesting to see the computer work in true fractions instead of converting everything to decimal numbers. This program first displays a blank equation: ``` 0/0 # 0/0 = ? ``` Each unknown flashes, in turn, for entry of a number operator. Lines 55 to 80 provide the necessary cross-multiplication. The result is available as X and Y in line 85, but the numbers may be large. Finding the least-common-denominator is the real programming problem. To test all the possibilities one by one is slow, so lines 90 to 125 limit the search to submultiples of X. Eventually this may become counter-productive; if further search is needed it reverts to one-by-one testing for the rest of the way. The result is displayed as: ``` 203/300 + 103/200 = 1 23/120 ``` I have worked out a machine language program which speeds it up further for large numbers. ## Source Code ``` 10 REM ***** FRACTIONS 15 DIM Z(5): LET Q$="#" 20 FOR n=1 TO 6 25 PRINT AT 25-PEEK 23689,0; FLASH (n=1);z(1); FLASH 0;"/"; FLASH (n=2);z(2); FLASH 0;" "; FLASH (n=3);q$; FLASH 0;" "; FLASH (n=5);z(5); FLASH 0;" = ";flahs(n=6);"?"; FLASH 0;CHR$ 8; 30 IF n=6 THEN GO TO 50 35 IF n=3 THEN INPUT Q$: LET z(3)=CODE q$: GO TO (50-15*(q$ >="0")) 40 INPUT q: LET z(n)=SGN q*INT ABS (q): GO TO (50-10*(z(n)=0)) 50 NEXT n 55 LET a=z(1)*z(5) 60 LET b=z(2)*Z(4) 65 LET c=z(2)*z(5) 70 LET d=z(1)*z(4) 75 LET x=a+b*(q$="+")-b*(q$="-")+(d-a)*(q$="*") 80 LET y=c+(b-c)*(z(3)=47) 85 LET x=SGN y*x: LET y=ABS y 90 REM *** Least Common Denom 95 LET a$=("-" AND x<0) 100 LET x=ABS x: LET a$=a$+(STR$ INT (x/y)+" " AND x >= y)+("0" AND x=0): LET x=x-INT (x/y)*y 110 FOR j=1 TO x: LET z=INT (x/j) 115 IF z=INT (x/(j+1)) THEN FOR j=z TO 1 STEP-1: LET z=j 120 IF INT (x/z)=x/z AND INT (y/z)=yz THEN GO TO 130 125 NEXT j 130 LET a$=a$+(STR$ (x/z)+"/"+STR$ (y/z) AND x) 135 PRINT a$: STOP: GO TO 10 ```