$x \geq m, f(x) = 1$
$x <m, f(x) = 0$
My best result so far is :
$$f(x) = \frac{ x-m + \left| x-m \right|}{2\left| x-m \right|} $$
But when $x = m$, it is invalid...
$x \geq m, f(x) = 1$
$x <m, f(x) = 0$
My best result so far is :
$$f(x) = \frac{ x-m + \left| x-m \right|}{2\left| x-m \right|} $$
But when $x = m$, it is invalid...
Let sgn be the sign function (present in most programming languages). Then this function should do it for a threshold $m$: $$\frac{\mathrm{sgn}(x-m)+1}{2}$$
Depending on the implementation of sgn, this gives $1/2$ for $x=m$. If you want it to output $1$ instead, then use $$\mathrm{ceil}((\mathrm{sgn}(x-m)+1)/2)$$
I ended up with :
$$f(x) = \operatorname{ceil}\left( \frac{ x-m + \left| x-m \right|}{2\left| x-m \right| + 1}\right)$$
Not very mathematic but usable for programming.
@Chrystomath's solution is somewhat better/shorter in term of programming.