Day of the week: Difference between revisions
Content added Content deleted
(→{{header|QL SuperBASIC}}: added output) |
(→{{header|QL SuperBASIC}}: added output) |
||
Line 684: | Line 684: | ||
==={{header|QL SuperBASIC}}=== |
==={{header|QL SuperBASIC}}=== |
||
<b>Works with:</b> [https://en.wikipedia.org/wiki/Sinclair_QL ''Sinclair QL''] <br> |
<b>Works with:</b> [https://en.wikipedia.org/wiki/Sinclair_QL ''Sinclair QL''] <br> |
||
...having a structured [https://en.wikipedia.org/wiki/SuperBASIC ''BASIC''] with MOD and quite unlike the ZX81's "zeroeth-generation" BASIC that's rather like using a calculator which |
...having a structured [https://en.wikipedia.org/wiki/SuperBASIC ''BASIC''] with MOD & DIV and quite unlike the ZX81's "zeroeth-generation" BASIC that's rather like using a calculator which also is without an integer type. Even so, one should still put forth the effort into optimising the code for the task at hand, as done below - which if implemented for the ZX81's routine would make it finish in a fraction of a second, even in slow mode, as multiplying by 13 with a division by 5 is slower than by 256 alone, as well as that two divisions by multiples of 100 are much slower than one by 16 as used in [gopher://sdf.org/0/users/retroburrowers/TemporalRetrology/cc/os ''Lachman's method''] of calculating the day of the week. |
||
<lang basic> |
<lang basic> |
||
Line 697: | Line 697: | ||
LET i$=m%*256+ 19300 : n%=i$(2TO 3)+ d% |
LET i$=m%*256+ 19300 : n%=i$(2TO 3)+ d% |
||
⚫ | |||
FOR count=S TO O |
FOR count=S TO O |
||
LET y$=count : w%=(y$(1TO 2)&"32"DIV 16+ count DIV 4+ count+ n%)MOD 7 |
LET y$=count : w%=(y$(1TO 2)&"32"DIV 16+ count DIV 4+ count+ n%)MOD 7 |
||
REM or by using w%=(y$(1TO 2)&"16"DIV 16+ count DIV 4+ count)MOD 7 as |
REM or by using w%=(y$(1TO 2)&"16"DIV 16+ count DIV 4+ count)MOD 7 as further optimisation |
||
⚫ | |||
IF w%=0 THEN PRINT count : count = count+ 4 |
IF w%=0 THEN PRINT count : count = count+ 4 |
||
END FOR count |
END FOR count |
||
Line 706: | Line 706: | ||
{{keypress|ctrl|space}} |
{{keypress|ctrl|space}} |
||
</lang> |
</lang> |
||
{{out}} |
|||
<pre>2011 |
|||
2016 |
|||
2022 |
|||
2033 |
|||
2039 |
|||
2044 |
|||
2050 |
|||
2061 |
|||
2067 |
|||
2072 |
|||
2078 |
|||
2089 |
|||
2095 |
|||
2101 |
|||
2107 |
|||
2112 |
|||
2118</pre> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |