I see many c & pascal source code to calculate pi(3.1415926535897932384626.....)

And I wander how fast it will be if I code it in asm?

sorry for my poor english. :grin:

And I wander how fast it will be if I code it in asm?

sorry for my poor english. :grin:

And I wander how fast it will be if I code it in asm?

Depends on the CPU speed ;)

Google has a pointer to the answer: http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=utf-8&q=.asm+masm+calculate+OR+approximate+pi+&btnG=Google+Search

http://www.programmersheaven.com/zone5/cat18/index.htm - look for "AsmPI" on the page :)

CPU speed is somewhat irrelevant in this case since this is primarily a comparison of the relative speed between code written in assembler and code written in a HLL language.

If the assembly code is optimized for the system you are using, it will DEFINITELY be faster than code written in any other language.

If you want to calculate PI with only up to 18 significant digits, this can be extremely fast and simple in assembler. That constant is already hard coded in the FPU with that precision. If you want to establish a new record for the number of decimal places of PI, I hope you have a lot of patience.

Raymond

If the assembly code is optimized for the system you are using, it will DEFINITELY be faster than code written in any other language.

If you want to calculate PI with only up to 18 significant digits, this can be extremely fast and simple in assembler. That constant is already hard coded in the FPU with that precision. If you want to establish a new record for the number of decimal places of PI, I hope you have a lot of patience.

Raymond

If you want to establish a new record for the number of decimal places of PI, I hope you have a lot of patience.

And a "titz-ripper" fast super computer if you're aiming to become the highest precision record holder, there are dedicated servers around the world with equally dedicated pi-geeks (or is it pi-greeks ;P ), they've been up and running for years, it'll take sometime to catch up.

fldpi

...probably not what your looking for tho ;)

...probably not what your looking for tho ;)

I don't get it

The only practical application for PI would be about 3 digits past the decimal point.

The number is transindental the same as the natural base ...so whats the point?

The only practical application for PI would be about 3 digits past the decimal point.

The number is transindental the same as the natural base ...so whats the point?

try searching for Borwein's formula or Gauss-Legendre algorithm or Ramanujan algorithm.

there are others but these are the ones I can remember... I can't guarantee their accuracy to X digits, since I've never implemented any of these in real life. Try searching. :grin:

IIRC, PI's can be use to seed a pseudo-random number generator... and construction/engineering stuff... and a rumor I heard that Cray Research is using the Ramanujan algo to calculate large values of PI to verify correct execution at boot time.

Don't ask me why the stuff above happens... I just read it from somewhere. I can't remember. :grin:

there are others but these are the ones I can remember... I can't guarantee their accuracy to X digits, since I've never implemented any of these in real life. Try searching. :grin:

IIRC, PI's can be use to seed a pseudo-random number generator... and construction/engineering stuff... and a rumor I heard that Cray Research is using the Ramanujan algo to calculate large values of PI to verify correct execution at boot time.

Don't ask me why the stuff above happens... I just read it from somewhere. I can't remember. :grin:

A few years ago, an extraction algorithm was discovered that can calculate the Nth digit of Pi (without having to know any of the previous digits). So, I think the whole quest to calculate Pi is kind of pointless, especially now.

And Pi has been proven to be irrational, so no matter how long you calculate, you'll never reach a final value. And as IWasTitan mentioned, it's practical use hardly ever exceeds a few dozen decimal places.

Why not waste your clock cycles on something worthwhile, like finding a cure for cancer or something. ;)

And Pi has been proven to be irrational, so no matter how long you calculate, you'll never reach a final value. And as IWasTitan mentioned, it's practical use hardly ever exceeds a few dozen decimal places.

Why not waste your clock cycles on something worthwhile, like finding a cure for cancer or something. ;)

Programming fast algorithms in pure assembler is inpracticable. My own implementation of Ramunjan type algorithm of the Chudnovsky Brothers (one of the fastes Algos.) is implemented to about 80% in assembler. More where possible but is pointless. The needed Algorithms are far to complicated to do it all in assembler. My own implementation calculate Pi with 1 Million decimal digits in about 13 seconds on P4 1.5GHz.

By the way: it's Borweins formula to calculate digits of Pi. But there exists today no such formular to calculate the decimal digits with this formular (only binary). The complexity of this algo. is higher if we want all succesive digits as any other algo.

Hagen

By the way: it's Borweins formula to calculate digits of Pi. But there exists today no such formular to calculate the decimal digits with this formular (only binary). The complexity of this algo. is higher if we want all succesive digits as any other algo.

Hagen

Found a program that calculates pi in "pure" assembler".

Raidu

Raidu

iblis: altought that Bailey-Borwein-Plouffe Algorithm is qite interesting, I wouldn't say that it's fast.

Well, there's some more algorithms: Pi Formulas.

Well, there's some more algorithms: Pi Formulas.

It's a digit extraction algorithm, it doesn't need to be fast.

iblis: altought that Bailey-Borwein-Plouffe Algorithm is qite interesting, I wouldn't say that it's fast.

Well, there's some more algorithms: Pi Formulas.

Slow ?

Check the ASM implementation here

It's the current record in hexadecimal digits.

multiply it's performance with all needed bits for Pi upto these bounds, then it is slow compared to most other algorithms. It depend on the goal what we want to compute. If we want only one bit on specific position then it is the fastest known one.

Jason P's website has source codes to pi programs, some of them are in assembly:

http://www.boo.net/~jasonp/pipage.html

If you want to try your hands at breaking some size and speed records, Stu's Pi Page has a list of what you'll be up against:

http://pages.istar.ca/~lyster/pi.html

Good luck!

http://www.boo.net/~jasonp/pipage.html

If you want to try your hands at breaking some size and speed records, Stu's Pi Page has a list of what you'll be up against:

http://pages.istar.ca/~lyster/pi.html

Good luck!

My mistake. I tried to use base 10 instead of 16 :(, but what can you expect at 2AM...

BTW. what kind of storage device are they using? Goddamn! 1 000 000 000 000 000 bits is nearly 114 TERABYTES!

My mistake. I tried to use base 10 instead of 16 :(, but what can you expect at 2AM...

BTW. what kind of storage device are they using? Goddamn! 1 000 000 000 000 000 bits is nearly 114 TERABYTES!

Iwabee, it seems you missed the point of the BBP algorithm: You can use it to calculate any hex digit of Pi without needing to calculate any of the preceding digits nor do you need to store any of the preceding digits.

I understood that. It's the other part I don't understand: why to calculate Pi if you are not storing it? Well... the 114TB part can be the answer, BUT IT'S NOT THE POINT! It's like deverlopin a program fo several years only to delete it after it's compiled. C'mon, what's the point?!?!

There is no point.