Today is the "Pi Day"...

Last week I was playing with Threads and Jobs project from OpenNTF. I needed a very long job to be run n the server-side. I have thought calculating pi digits would be a cool selection :)

I found a Javascript-based Spigot algorithm by Stephen R. Schmitt and easily converted to Java (sorry about the code!).

Notice that, on an average machine it calculates 10,000 digits in less than a minute. Now consider, ENIAC has calculated 2037 digits in 70 hours in 1949!  

Pi Pie at Delft University

However, to calculate trillion digits would be tough with this algorithm. Because we need a large String buffer and a large integer array for calculation. Integer array is around 3.5 times the digit count and string buffer has one chars per digit. So we are limited with the heap size. In a non-XPages environment, if you don't keep string buffer, you would be able to calculate 2.5 million digits with standard memory :)

Anyway, it was fun and I wanted to share it. Here is the screencast:



You can download the database here.
Serdar Basegmez   |   March 14 2013 10:45:00 AM   |    Development  Fun  Java  XPages    |  
  |   Next   |   Previous

Comments (3)

Gravatar Image
Stephen Hood       03/14/2013 5:11:01 PM

New copy worked. Thanks for the quick response.

Nothing to be sorry about :)

Gravatar Image
Serdar Basegmez    http://lotusnotus.com/en    03/14/2013 5:05:42 PM

Stephen,

I just forgot to change ACL before submitting.

Design is not locked but if you place the database into the server, you won't be designer by default so you experience this problem. You can either;

- Open the database in you notes client locally, so ACL will be overriden.

- Or open the database on server in Full Access Mode.

- Or create a database copy by unchecking ACL in "New Copy" dialog

Either way, you can add yourself as the manager and you can play with it.

Sorry :)

Gravatar Image
Stephen Hood       03/14/2013 4:53:39 PM

Hi Serdar, this is a bit off topic but I was just looking at the veryshorturl project on openntf. It looks like the design is locked down rather than having the default user as manager so it can be modified. Was that intentional or an oversight?