Output Pi without math

PHP - 22 bytes

<?=date('n.j',8899e5);

Pi Day in year 1998 was really cool!


C, 39

Assumes the machine is little-endian and uses IEEE floating-point standard.

main(){printf("%.2f",*(float*)"P@I@");}

The fun fact is that "P@I@" is actually not related to PI but is equivalent to 0x40494050 which is the representation of 3.144550323486328

http://ideone.com/uXVEtl


dc, 11 9 bytes

zE[.]znPp
  • z Push current stack depth (0) onto the stack
  • E Push E16 (==1410)
  • [.] Push the string "."
  • z Push current stack depth (3) onto the stack
  • n Pop 3 and print as number
  • P Pop "." and print as char
  • p Pop 14 and print as number with newline

Output:

$ dc <<< zE[.]znPp
3.14
$ 

Tags:

Pi

Code Golf