Jensen's Device: Difference between revisions
Content deleted Content added
4thcompiler (talk | contribs) Added uBasic/4tH version |
|||
Line 331: | Line 331: | ||
5.18737752 |
5.18737752 |
||
</pre> |
</pre> |
||
==={{header|uBasic/4tH}}=== |
|||
Since uBasic/4tH does not support floating point numbers, fixed point has to be used. Of course, precision suffers significantly. |
|||
<syntaxhighlight lang="qbasic">' ** NOTE: it requires a 64-bit uBasic; number ranges are limited. ** |
|||
If Info("wordsize") < 64 Then Print "This program requires a 64-bit uBasic" : End |
|||
Dim @i(1) |
|||
i = 0 ' fake something that resembles a pointer |
|||
Print Using "+?.####";FUNC(_Ftoi(FUNC(_Sum(i, 1, 100, _Term)))) |
|||
End |
|||
_Sum |
|||
Param (4) |
|||
Local (1) |
|||
e@ = 0 |
|||
For @i(a@) = b@ To c@ : e@ = e@ + FUNC(d@) : Next |
|||
Return (e@) |
|||
_Term Return (FUNC(_Fdiv(1, @i(i)))) |
|||
_Fdiv Param (2) : Return ((a@*16384)/b@) |
|||
_Ftoi Param (1) : Return ((10000*a@)/16384)</syntaxhighlight> |
|||
{{Out}} |
|||
<pre>5.1850 |
|||
0 OK, 0:313 </pre> |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |