I obviously needed to try myself.
First two attempts:
$ scale = 100*1000*1000
$ nit = 1000
$ pi = 0
$ i = 1
$ sign = 1
$ loop:
$ if i .gt. nit then goto endloop
$ pi = pi + sign * scale / (2 * i - 1)
$ sign = -sign
$ i = i + 1
$ goto loop
$ endloop:
$ pi = 4 * pi
$ write sys$output f$fao("The value of pi is approximatetly: !SL.!8ZL",
pi / scale, pi - (pi / scale) * scale)
$ exit
get 2 decimals correct (can be increased to 4 by increasing nit
to 100000, but then it becomes a CPU benchmark!)
$ scale1 = 100 * 1000
$ scale2 = 1000
$ scale = scale1 * scale2
$ nit = 100
$ pi = 0
$ i = 1
$ sign = 1
$ loop:
$ if i .gt. nit then goto endloop
$ pi = pi + sign * scale / (2 * i - 1)
$ sign = -sign
$ i = i + 1
$ goto loop
$ endloop:
$ pi = pi + sign * (nit * nit + 1) * scale1 / (4 * nit * nit * nit + 5 *
nit) * scale2
$ pi = 4 * pi
$ write sys$output f$fao("The value of pi is approximatetly: !SL.!8ZL",
pi / scale, pi - (pi / scale) * scale)
$ exit
get 4 decimals correct (and are still fast)
Arne
PS: No need to state that DCL is one of the worst possible
languages for such a task.