* { adam: conrad; }
Adam Conrad

Head of Product for @starstreet, DJ as @deejayacon, front-end developer. I lift things up and put them down, too.

TwitterLinkedIn

Search

March 21st, 4:29pm 0 comments

How to Calculate Pi in C

Somebody on Forrst wanted to calculate Pi in C and was using an incredibly convoluted algorithm. I was quite certain that it was a simple trigonometric function. Turns out, PI is good enough if you just use 4 * atan(1) or 4 * atan2(0,-1). If you’re feeling extra ambitious, I guess you could implement the Brent-Salamin Algorithm or try your hands at the Monte Carlo Method.

Posted