Pathological floating point problems: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
Line 1,486:
Bank balance after 25 years: $0,04
Rump f(77617, 33096): -0,827396059946821</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
numfmt 10 0
proc task1 . .
print "--- Task 1 pathologic ---"
vpp = 2
vp = -4
for i = 3 to 100
v = 111 - 1130 / vp + 3000 / (vp * vpp)
if i <= 8 or i = 20 or i = 30 or i = 50 or i = 100
print i & ": " & v
.
vpp = vp
vp = v
.
.
task1
print ""
#
proc task2 . .
print "--- Task 2 pathologic ---"
e = 2.718281828459045
bal = e - 1
for i = 1 to 25
bal = bal * i - 1
.
print "Balance after 25 years: $" & bal
.
task2
print ""
proc mul f . bal bal$[] .
for i = len bal$[] downto 1
dig = number bal$[i]
h = dig * f + c
bal$[i] = h mod 10
c = h div 10
.
bal += c
.
proc task2ok . .
print "--- Task 2 OK ---"
bal = 2
bal$[] = strchars "7182818284590452353602874713526624977572470"
bal -= 1
for i = 1 to 25
mul i bal bal$[]
bal -= 1
.
print "Balance after 25 years: $" & bal & "." & substr strjoin bal$[] 1 16
.
task2ok
</syntaxhighlight>
{{out}}
<pre>
--- Task 1 pathologic ---
3: 18.5000000000
4: 9.3783783784
5: 7.8011527378
6: 7.1544144810
7: 6.8067847369
8: 6.5926327687
20: 98.3495031222
30: 100.0000000000
50: 100
100: 100
 
--- Task 2 pathologic ---
Balance after 25 years: $-2242373258.5701580048
 
--- Task 2 OK ---
Balance after 25 years: $0.0399387296732302
</pre>
 
=={{header|Excel}}==
2,083

edits