Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I did enjoy the one which computes π;

> Naturally, a more accurate value can be obtained by using a bigger program.

I think that's a first for me.



Isn't there an obfuscated C or Perl competition program that also estimates pi by measuring its own code in some way?

Edit: Oh yes, it's "westley" from 1988: https://www.ioccc.org/years-spoiler.html#1988_westley


I made a JavaScript port, that might be easier to decipher if you are more familiar with js than C: https://quaxio.com/pi.html


Do you mind me asking, what does the last calculation do: pi=(pi * 100 | 0 ) / 100;

EDIT: Ah, nvm. It's truncating the result to 2 decimal places.


|0

There are just too many ways in JS to say Math.floor


https://www.cise.ufl.edu/~manuel/obfuscate/pi.c

If I remember correctly, this program also calculates pi more precisely the larger the circle.


That's originally westley.c from IOCCC 1988. As that site says:

> Unless otherwise indicated, the code comes from the International Obfuscated C code contest.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: