--- title: "Something strange about “VAL”" type: "article" slug: "something-strange-about-val" url: "http://localhost/article/something-strange-about-val/" markdown_url: "http://localhost/article/something-strange-about-val.md" published_at: "2020-10-27T17:13:30+00:00" modified_at: "2026-08-01T14:01:34+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "It you look at the program below, you are inclined to doubt the good judgement of the author, putting \"VAL\" all over. But when you program it and compare it with the way it is normally written, you find that it uses 14 BASIC bytes (12 %) less than the conventional program with 139 bytes.…" category: - name: "Quarters" slug: "quarters" taxonomy: "category" url: "http://localhost/category/periodicals/quarters/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - 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 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Heinz Grote" slug: "heinz-grote" taxonomy: "indiv" url: "http://localhost/indiv/heinz-grote/" publication: "QuarTerS" publication_r: id: 21505 title: "QuarTerS" type: "periodical" url: "http://localhost/periodical/quarters/" authors: "Heinz Grote" authors_r: - name: "Heinz Grote" slug: "heinz-grote" taxonomy: "indiv" url: "http://localhost/indiv/heinz-grote/" issues_articles: - id: 37907 title: "Quarters Fall 1986" type: "issue" url: "http://localhost/issue/quarters-fall-1986/" pages: "12" pubdate: "Fall 1986" archive_link: false volumeissue: "v2n3" --- # Something strange about “VAL” It you look at the program below, you are inclined to doubt the good judgement of the author, putting “VAL” all over. But when you program it and compare it with the way it is normally written, you find that it uses 14 BASIC bytes (12 %) less than the conventional program with 139 bytes. This is a consequence of the way in which numbers are programmed by the T/S computers. In order to save execution time, the BASIC program contains both the original number and the normalized floating point equivalent. If you use the VAL function, this is not the case. You add the 3 codes for VAL and 2 quotation marks but you gain 6 code bytes (one for the number indicator, and five for the normalized floating point number). While the running time for the standard program is 5 seconds, the one with the VAL requires 13 seconds. This example shows that in order to save 14 memory spaces (12%) you sacrifice 8 seconds (160 %) execution time. #### Listing: Standard Floating Point Variables ``` 200 LET A=2.5 210 FOR I=1 TO 255 220 IF I>200 THEN GO TO 250 230 LET A=A-I/2 240 GO TO 260 250 LET A=A+I+1.5 260 NEXT 270 PRINT A ``` #### Listing: VAL Variables ``` 200 LET A=VAL "2.5" 210 FOR I=VAL "1" TO VAL "255" 220 IF I>VAL "200" THEN GO TO VAL "250" 230 LET A=A-I/VAL "2" 240 GO TO VAL "260" 250 LET A=A+I+VAL "1.5" 260 NEXT I 270 PRINT A ```