Irrational expected value with rational definitions Is there some probability distribution that can be implemented/defined/etc. without irrational numbers such that it returns 1 an irrational proportion $P$ of the time and 0 the rest of the time, for any irrational probability $P$? If not, for what irrational $P$ can this be done? I am specifically trying for quadratic irrationals.
When I assume I have some random infinite sequence of bits to use, I want $\Bbb E(X) = \frac 12 \Bbb E(X_0) + \frac 12\Bbb E(X_1)$, where $X_0, X_1$ are results after getting 0 or 1 as the first bit respectively, but this prevents getting irrational from rational it seems, since the two expected values on the right must be irrational, but can't without starting irrationals. This would imply that it needs to be a more complicated process.
I want this to be a distribution that a computer program could in theory run, where irrational numbers cannot occur but I still want an irrational probability.
Edit: In principle I would like to have no approximate arithmetic, since if I could I could just generate a random floating point number between 0 and 1 and check if it's less than the given P (represented inexactly). I am fine with programs that have an indefinitely long running time as long as they are fast in the average case.
Edit: I really want a way to do this for any quadratic irrational, but if it isn't possible I would want to know that it is impossible instead.
 A: We start with a unit square $[0,1]\times [0,1]$
In each iteration we divide the square in four, we generate a pair $(X_n,Y_n)$, where the components  are iid Bernouli with $p=1/2$, and we select one of the four sub-squares according with the result. We stop whenever the current square does not intersect the unit circle. We output $Z=1$ if the final square is inside the circle, $Z=0$ otherwise.
So, we've generated, using only rational operationts, a Bernoulli with $P(Z=1)=\pi/4$. The number of iterations is unbounded, true, but the average is finite.
A similar and simpler way, in one dimension, dividing the unit segment and stopping when the extremes squared are both smaller or greater than $1/2$ generates a Bernoulli with $p=1/\sqrt{2}$
A: Randomly generate the digits of a binary representation of a number between 0 and 1, and stop when the expansion certifies the number as being above or below a given threshold $p$.  Output 1 if below and 0 if above. 
The output is 1 with probability $p$.
This method is attributed to von Neumann. 
A: In the case of a quadratic irrational $p=q+\sqrt{s}$, where $q$ is a rational number, $s$ is a positive rational number, and the overall quantity is between $0$ and $1$, you can sample a random variable which is $1$ with probability $p$ and $0$ with probability $1-p$ as follows. Suppose $B_k$ are iid Bernoulli(1/2) variables. Introduce $x_n=\sum_{k=1}^n 2^{-k} B_k$ and $x_\infty = \lim_{n \to \infty} x_n$. Then $x_\infty$ is uniformly distributed in $[0,1]$. So you want to return $1$ if $x_\infty \leq p$ and otherwise return $0$. 
Here's the key point: $x_n>p$, then $x_\infty>p$. On the other hand, if $x_n+2^{-n} \leq p$, then $x_\infty \leq p$. The truth value of these inequalities can be detected by using a quadratic with rational coefficients which has a root at $p$. One of these is $x^2-2qx+q^2-s$. So if $x_n^2-2qx_n+q^2-s>0$, then you return $0$. If $(x_n+2^{-n})^2-2q(x_n+2^{-n})+q^2-s \leq 0$, then you return $1$. Otherwise you get another digit and repeat. The process terminates with probability $1$.
