Happy π Day. The goal of this question is to calculate the area for a circle of radius 3, where A = πr².
The catch is that you have to use the constant π that is defined in a different language than the one you are programming in. For example, you can write a C program that uses Fortran's
MATH::PI, or a Python program that uses Java's
- Your code must use a stored value of π from a different language for the calculation. (i.e. it must be stored in a constant or math library.)
- All of the code for your program must fit in a single file. For example, You cannot write one program in C to print π, then another in Java to run the C program. (However, you can write a Java program that writes and compiles a C program by itself.)
- You cannot download π from a webpage and claim that your constant came from PHP/ASP/HTML.
Here is an example that runs in Bash, and uses Python's stored
#!/bin/bash PI=`python -c 'import math; print math.pi'` bc -l <<< "3 * 3 * $PI"
This is a Popularity Contest, so the entry with the most votes after a week wins.
Edit: After one week, the prize goes to DigitalTrauma with 93 points. Thanks for the awesome assembler tip - I did not know that the the FPU stored the constant in hardware. I expected this contest to be about finding funny ways to throw clock cycles away, but that one could actually save a few.
* Image courtesy of: http://xkcd.com/10/