Function that converts values to 0 or 1 I'm looking for a function that takes a number between 0 and 1 and converts it into 0 if number is between 0 and 0.5, and into 1 if number is between 0.5 and 1.
So far I've got the first part, f(x) = max(x - 0.5, 0.0), but can't figure out how to continue the formula for the second part.
EDIT: The idea is to write it as one expression to avoid if branching.
 A: I don't know if this is answer your question, but could it be the Heaviside theta function $\theta(x-0.5)$? You can write it as the derivative of the maximum function:
$$
\theta(x-0.5) = \frac{d}{dx}\max\{x-0.5,0\}=
\begin{cases}
0 & \text{ if } x < 0.5\\
1 & \text{ if } x > 0.5
\end{cases}
$$
A: $\def\sign{\operatorname{sign}}$
Using another piecewise function,
which is often included in a standard set of functions:
\begin{align} 
 \sign x &=
   \begin{cases} 
    -1 & \text{if } x < 0
  \\
  \phantom{-}0 & \text{if } x = 0
  \\
  \phantom{-}1 &  \text{if } x > 0
   \end{cases}
   \quad,
 \\
 f(x)&=\tfrac12(\sign(2x-1)+1)\cdot \sign(2x-1)
\end{align}  
A: Using the Iverson bracket, one could describe the function simply as $[x>0.5],\; x\in [0,1]$.
A: "I'm looking for a function that takes a number between 0 and 1 and converts it into 0 if number is between 0 and 0.5, and into 1 if number is between 0.5 and 1."
And you've already found it.  
A function is any relation (set of ordered pairs) where the first term is mapped to a unique second term.  That is all.  A function doesn't have to have a rule or formula to make it calculable.  ANything that can be unambiguously described is an acceptable function.
So the function you want is:
$f(x) =\begin{cases} 0 & \text {if } 0 \le x < .5 \\ 1 & \text {if } .5 \le x \le 1\end{cases}$.
That's it!  That is all you need to say.
Unless you are asking for a mathematical formula.  
But in that case you should ask for a formula, not a function.  You already have the function.  
It is "a function that takes a number between 0 and 1 and converts it into 0 if number is between 0 and 0.5, and into 1 if number is between 0.5 and 1".
A: You could just use a piecewise function, but if you're looking for a different option, this should work:
$$f(x) = \lfloor2x\rfloor$$
If $0<x<0.5$, then $0<2x<1$, so $\lfloor2x\rfloor=0$ and if $0.5<x<1$, then $1<2x<2$, so $\lfloor2x\rfloor=1$.
