Jensen's Device: Difference between revisions

Content added Content deleted
(Added uBasic/4tH version)
(Added various BASIC dialects (Applesoft BASIC, Chipmunk Basic, Gambas, GW-BASIC, Minimal BASIC, MSX Basic, QBasic, QB64, Quite BASIC, Run BASIC and True BASIC))
Line 297: Line 297:


=={{header|BASIC}}==
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
Same code as [[#GW-BASIC|GW-BASIC]]

==={{header|BASIC256}}===
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="basic256">subroutine Evaluation()
<syntaxhighlight lang="basic256">
call Evaluation()
end

subroutine Evaluation()
lo = 1 : hi = 100 : temp = 0
lo = 1 : hi = 100 : temp = 0
for i = lo to hi
for i = lo to hi
Line 305: Line 312:
next i
next i
print temp
print temp
end subroutine
end subroutine</syntaxhighlight>

call Evaluation()
end</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>5.18737751764</pre>
5.18737751764
</pre>


==={{header|BBC BASIC}}===
==={{header|BBC BASIC}}===
Line 328: Line 330:
DEF FNreciprocal = 1/i</syntaxhighlight>
DEF FNreciprocal = 1/i</syntaxhighlight>
Output:
Output:
<pre>
<pre>5.18737752</pre>

5.18737752
==={{header|Chipmunk Basic}}===
</pre>
{{trans|QBasic}}
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="vbnet">100 call evaluation
110 end
120 sub evaluation()
130 lo = 1
140 hi = 100
150 temp = 0
160 for i = lo to hi
170 temp = temp+(1/i)
180 next i
190 print temp
200 end sub</syntaxhighlight>

==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Sub Evaluation()

Dim i As Integer, lo As Integer = 1, hi As Integer = 100
Dim tmp As Float = 0

For i = lo To hi
tmp += (1 / i)
Next
Print tmp

End Sub

Public Sub Main()

Evaluation

End </syntaxhighlight>

==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
{{works with|BASICA}}
{{works with|Applesoft BASIC}}
{{works with|Chipmunk Basic}}
{{works with|QBasic}}
{{works with|QB64}}
{{works with|Quite BASIC}}
{{works with|MSX BASIC}}
<syntaxhighlight lang="qbasic">100 GOSUB 120
110 END
120 REM Evaluation
130 LET A = 1
140 LET B = 100
150 LET T = 0
160 FOR I = A TO B
170 LET T = T + (1/I)
180 NEXT I
190 PRINT T
200 RETURN</syntaxhighlight>

==={{header|Minimal BASIC}}===
<syntaxhighlight lang="qbasic">100 GOSUB 120
110 GOTO 210
120 REM Evaluation
130 LET A = 1
140 LET B = 100
150 LET T = 0
160 FOR I = A TO B
170 LET T = T+(1/I)
180 NEXT I
190 PRINT T
200 RETURN
210 END</syntaxhighlight>

==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
Same code as [[#GW-BASIC|GW-BASIC]]

==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|Run BASIC}}
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
{{works with|True BASIC}}
<syntaxhighlight lang="qbasic">CALL EVALUATION
END

SUB Evaluation
LET lo = 1
LET hi = 100
LET temp = 0
FOR i = lo TO hi
LET temp = temp + (1 / i)
NEXT i
PRINT temp
END SUB</syntaxhighlight>

==={{header|QB64}}===
Same code as [[#QBasic|QBasic]]

==={{header|Quite BASIC}}===
Same code as [[#GW-BASIC|GW-BASIC]]

==={{header|Run BASIC}}===
Same code as [[#QBasic|QBasic]]

==={{header|True BASIC}}===
Same code as [[#QBasic|QBasic]]

==={{header|uBasic/4tH}}===
==={{header|uBasic/4tH}}===
Since uBasic/4tH does not support floating point numbers, fixed point has to be used. Of course, precision suffers significantly.
Since uBasic/4tH does not support floating point numbers, fixed point has to be used. Of course, precision suffers significantly.