Bug #51
Int arithmetic (wrong value then VM crash)
| Status: | Assigned | Start date: | ||
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% | ||
| Category: | Virtual Machine | |||
| Target version: | - | |||
| Platform: | Triage Stage: | |||
| Resolution: |
Description
Could be a nice code example :)
Sadly some arithmetic debugging is still needed :(
// Spigot by Jeremy Gibbons, using William Gosper formula
public define Int
div(Int a,Int b)
=
if a / b is
{
failure then 0,
success(d) then if d is (q,r) then q
}.
global define One
pi_gosper_gibbons(List(String) args)
=
( (Int q,Int r,Int t,Int i) |-g->
with
u = 3*(3*i+1)*(3*i+2),
y = div(q*(27*i-12)+5*r,5*t),
print(abs_to_decimal(y));
g(10*q*i*(2*i-1),10*u*(q*(5*i-2)+r-y*t),t*u,i+1);
unique
)
(1,180,60,2).
History
#1
Updated by Alain Prouté over 17 years ago
- Status changed from New to Assigned
Thank you for this very nice example. Actually, division for Int is still buggy. I hope this will be fixed soon.