[Question]
  [
**Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers.
 
 
---
**Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/25670/edit).
Closed 6 years ago.
[Improve this question](/posts/25670/edit) 
In as few bytes as possible, your job is to write a program that outputs:
```
3.14
```
In celebration of a late Pi day of course! :)
## Rules
You can do it anyway you like, but there are some restrictions.
* You may **not** use arithmetic operations anywhere in your program. This includes `+`, `-`, `*`, `/`, `%`, `^` (exponentiation), etc... This also includes incrementing (usually `++`), decrementing (`--`), **bitwise operations**, and any built in functions that can be used as a replacement such as `sum()`, `prod()`, `mod()`, `double()`, `pow()`, `sqrt()`, `inc()`, `dec()`, etc... (Author's discretion)
* The digits `3`, `1`, and `4` may **not** appear anywhere in your code.
* You may **not** use any predefined variables/constants that your language may have as a replacement for `3`, `1`, and `4`. (Author's discretion)
* You may also **not** use any trigonometric functions such as `sin()`, `cos()`, `tan()`, `arcsin()`, `arccos()`, `arctan()`, `sinh()`, `cosh()`, `tanh()`, etc... (Author's discretion)
* You may **not** use built-in or predefined values of Pi (or `3.14`). *No web requests*.
* Your program **cannot** require input of any kind (besides running it).
* `3.14` is the **only** thing that you may output, it cannot be part of some longer/larger output..
## Winner
The answer with the least amount of bytes on **April 18th** wins. Good luck!
Looking forward to clever answers from clever minds! Malbolge anyone? :P
  
[Answer]
## PHP - 22 bytes
```
<?=date('n.j',8899e5);
```
Pi Day in year 1998 was really cool!
[Answer]
## 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>
[Answer]
# [dc](http://www.gnu.org/software/bc/manual/dc-1.05/), 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
$ 
```
[Answer]
# JavaScript (*ES5*) 20 bytes
A variation of m.buettner's JS solution.
```
(x='.'+0xE).length+x
```
---
# Edit: JavaScript (*ES5*) 18 bytes
A variation of ComFreek's idea of using the base64 decode function.
```
atob('Mw')+'.'+0xE
```
---
# Edit: Javascript (*ES5*) 16 bytes
If the unary `+` operator is allowed to cast a string to a number, it can be reduced to:
```
+atob('MDMuMTQ')
```
[Answer]
# Haskell, 41 bytes
When is pi day in Australia?
```
p=(\(a:n:y:t:i:m:e:_)->[m,a,t,e])['.'..]
```
Edited to add: like the other Haskell answer, that outputs a string, so has quotes. You can score 33, and be strictly within the rules, but it's less fun:
```
p=putStr$map([','..]!!)[7,2,5,8]
```
[Answer]
**Morse Code, 33 Bytes**
```
morse -d ...-- .-.-.- .---- ....-
```
Technically speaking, the information only takes 21 bytes.
[Answer]
# J - ~~15~~ ~~11~~ 10 char
Made it shorter, using the fantastic `i:`.
```
6{i:6.28j8
```
Explained:
* `6.28j8` - The complex number 6.28 + 8i.
* `i:` - This is where the magic happens. `i:` on a complex number A+Bi, B≠0 takes B+1 equally spaced points from the interval [-A,A].
* `6{` - Take element at index 6, which just so happens to be 3.14.
Previously, we had the following nonsense:
```
|.'.'2}":22b8d5
```
Explained by explosion:
```
         22b8d5  NB. 8d5 in base 22 = 4163
       ":        NB. convert to string
  '.'2}          NB. change character at index 2 to '.'
|.               NB. reverse to make '3.14'
```
[Answer]
# CJam - ~~8~~ 6
```
S`,'.E
```
CJam is a new language I am developing, similar to GolfScript - <http://sf.net/p/cjam>.  
Here is the explanation:
`S` is a variable preinitialized to space (" ")  
``` generates the string representation of the last value - which is exactly `" "` (3 characters)  
`,` calculates the string length (3)  
`'.` is the dot character  
`E` is a variable preinitialized to 14; 3, 1 and 4 are not allowed but it doesn't say anything about 14 :) 
Credits to Doorknob for the backtick idea
[Answer]
# Linux command line, 35 bytes
This one is nowhere near winning, but here it is for the fun of it:
```
ping -w2 67502862|grep -oP '.\..\d'
```
Output (after 2 seconds):
```
$ ping -w2 67502862|grep -oP '.\..\d'
3.14
$
```
[Answer]
# GolfScript, ~~18~~ ~~13~~ 12
```
'.'.`,\.,n`,
```
Old version:
```
'...','.'.,'....',
```
It's very artistic, only 3 unique characters! ;)
How it works:
```
# cmd   # stack
'...',  # 3
'.'.    # 3 '.' '.'
,       # 3 '.' 1
'....', # 3 '.' 1 4
```
Here's an explanation of the 12-char version (much more interesting, IMO):
```
'.' # '.'
.`, # '.' 3
\.  # 3 '.' '.'
,   # 3 '.' 1
n`, # 3 '.' 1 4
```
It works because `n`,` is `4`, since `n`` is `'"\n"'`. Same logic for `'.'`,`. It also swaps instead of creating a new string to save a char (thanks @algorithmshark).
Alternate version:
```
'pi ','.'.,'day!',
```
or
```
'Hi ','.'.,'PPCG',
```
Or anything in those strings, really. :P
[Answer]
OP's answer.
# Mathematica, 21 20 18
This feels cheap...
```
Range[2,5,.06][[20]]
```
or
```
Range[2,5,.02][[58]]
```
Figured out how to make it 18:
```
Range[-.86,5][[5]]
```
# Haskell, 49 48 12
(48 includes the new line character)
```
p=[-6..]
r=concat$show(p!!9):".":(show$p!!20):[]
```
Run it by calling the `r` function.
Using the method as with Mathematica above, you can type this into GHCi:
```
[-2.86..]!!6
```
# Java, 87 86
```
class P{public static void main(String[]a){System.out.print("tri".length()+"."+0xe);}}
```
# Scala, 27
Translated from Java as suggested by **Score\_Under**. (I don't really know Scala)
```
print("tri".length+"."+0xe)
```
[Answer]
# Bash, 50
Help/error messages aren't external resources, they're a command's output!
If anything is rule abuse, this is it. It uses the coincidence that the help message given to `STDERR` by the exact command
```
ping6
```
is 314 characters long (at least on Ubuntu 13.10 with `iputils-121221`). EDIT: I appreciate that this is much less portable than I expected...
```
m=`ping6|&wc -c`
false
o=$?
echo ${m:0:o}.${m:o:2}
```
The first line takes the character length of the help message and stores it in a variable.
As in my other answers, the next few lines obtain the number 1 by taking the exit status of `false` (not very portable but this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") after all!), then use that value to insert a decimal point in the last line
Output: `3.14`
[Answer]
# Bash+TeX 28 bytes
If you have TeX installed:
```
tex -v|head -c8|cut -d\  -f2
```
The version number of TeX asymptotically approaches pi as the software improves. So, as time goes on, you can use this (nonconforming) implementation to print more and more digits!
```
tex -v|cut -d\  -f2 | head -n1
```
This printed 3.1415926 back in 2011; as of January 2014, it will print 3.14159265.
[Answer]
## JavaScript, 20 bytes
```
'...'.length+'.'+0xe
```
Use it in a console, so that the result is directly printed. Otherwise, `alert(...)` will add another 7 characters.
Same as my other answer, I just noticed it's a lot shorter in JS.
The idea of using `0xe` for 14 is taken from the OP's submission with the OP's kind permission.
[Answer]
# GNU date, 17 bytes
```
date -d2/5 +%u.%y
```
This one only guaranteed to work this year, but I don't see any limitation in the rules about this ;-)
The `+` is simply indicates the start of the format specifier for `date` and is not an arithmetic addition. Same with the `-`, indicating input date.
Output:
```
$ date -d2/5 +%u.%y
3.14
$
```
[Answer]
# Bash, 17 bytes
```
tr 0 .<<<$[62#MC]
```
---
# Dash, 41 bytes
```
perl -pechomp,s/./$./<<$
..
.
```
[Answer]
## Bash 23 22
```
seq 2 .02 5|sed -n 58p
```
---
## Shell (without history expansion) 20
```
seq 2 .02 5|sed 58!d
```
[Answer]
## Python, 39 or 28 ~~47 or 34~~
(Thank you Score\_Under for golfing it down so much)
```
print"%s.%s%c"%(len('aaa'),len('a'),52)
```
`+` here is the string concatenation operator, not addition.
Copying the `0xe` trick from the OP, here's 28 chars with help from @psal
```
print('%X.%s'%(675,0xE))[2:]
```
Old versions:
```
print str(len('aaa'))+'.'+str(len('a'))+chr(52)
print str(len('aaa'))+'.'+str(0xe)
print"%s.%s"%(len('aaa'),0xe)
```
[Answer]
# GolfScript, 8 bytes
```
'??.'(\(
```
This program contains non-printable ASCII characters, so it cannot be directly pasted here. Instead, the question marks in the code above should be replaced with the bytes `03` and `0E` in hexadecimal.
For convenience, here's a hex dump of the actual program. Unix / Linux users can run this hex dump through `xxd -r` to reconstruct the program:
```
0000000: 2703 0e2e 2728 5c28                      '...'(\(
```
Explanation:
* The first five bytes of the program form a single-quoted string literal encoding the three characters with the ASCII codes 3, 14 and 46 (= ASCII period).
* `(` chops the first character off the string and pushes its ASCII code (3) on the stack. `\` swaps the top two items on the stack, pulling the string back to the top, and the second `(` chops another character off the string, again pushing its ASCII code (14) on the stack.
At the end of the program, the stack (excluding the empty input string) therefore looks like this:
```
3 "." 14
```
At the end of the program, the default behavior of the GolfScript interpreter is to stringify and print everything on the stack, yielding the desired output.
[Answer]
# bash -- 39
We all know that the first few digits of Pi can be computed from the following statement:
> 
> May I have a large container of coffee
> 
> 
> 
We need only 2 decimal places, right?
```
m=May
i=I
h=have
echo ${#m}.${#i}${#h}
```
[Answer]
## Mathematica - 78
```
DateList["March"<>ToString@FromDigits@"E"]~DateString~{"MonthShort",".","Day"}
```
[Answer]
## Perl, 15 20 bytes
```
print 05706=~s/0/./r
print 0xbc6=~s/0/./r
```
[Answer]
# [tr](http://www.gnu.org/software/coreutils/manual/html_node/tr-invocation.html) + Bash, 17 bytes
```
tr a-j 0-9<<<d.be
```
The `-` chars here are not arithmetic subtraction operators. They indicate range.
Output:
```
$ tr a-j 0-9<<<d.be
3.14
$
```
[Answer]
## BASH, 57
This is longer than most answers, but there is nothing bad in trying.
```
f=`echo aaaaaaaaaaaaa|wc -c`;e=`echo aa|wc -c`;echo $e.$f
```
gives
```
3.14
```
[Answer]
## C, 36
```
main(){printf("%d\b.%o\b",' ','`');}
```
[Answer]
## JavaScript - 23 bytes
```
atob('Mw')+atob('LjE0')
```
Thanks to nderscore (see his comments)!
[Answer]
**C#**
```
 ((int)'ĺ').ToString("#\\.##");
```
ĺ is character 314, not a pre-defined variable or constant.
the .ToString formats the output into a digit, a period, and then 2 more digits.
[Answer]
# GolfScript, ~~13~~ 10
```
{xy}.*'.'\
```
Thanks to **Ilmari Karonen** for the improved version!
`x` and `y` are non-printable characters (see <http://www.asciitable.com/> for more info), respectively `ETX` and `SO`, which decode to 3 and 14.
What this code does should be pretty clear.
**Note:** The following rule
`You may not use any predefined variables/constants that your language may have as a replacement for 3, 1, and 4. (Author's discretion)`
is not broken, since ASCII characters are neither variables, nor constants.
[Answer]
New to the site and can't write comments yet, so I'll post it here. Just wondering about this Javascript solution: 
```
'...'.length+'.'+0xe
```
and this rule:
*3.14 is the only thing that you may output, it cannot be part of some longer/larger output..*
If I run this code in my browser console, I get:
```
"3.14"
```
or using Node at the command line:
```
'3.14'
```
but if I run this code:
```
parseFloat('...'.length+'.'+0xe)
```
I get:
```
3.14
```
Using Node.js to run a .js file, I can write:
```
console.log('...'.length+'.'+0xe)
```
and get:
```
3.14
```
[Answer]
## Mathematica, 56 bytes
```
(l=ToString@StringLength@#&)@"..."<>"."<>l@"."<>l@"...."
```
Not much to say. I'm generating the digits as string lengths and concatenate them.
]