Is there a real continuous function of a Cube? Sorry if this seems like a basic question, but I'm having troubles finding an answer in my research. I'm looking for a function that if given a test point (x, y, z) will return a real value describing whether the given point is


*

*On the surface of the shape
$$f(x) = 0$$

*Inside the volume of the shape
$$f(x) > 0$$

*Or outside the volume of the shape
$$f(x) < 0$$


I've found such equations for a sphere and other shapes but cubic, and in general faceted shapes have eluded me. Unfortunately I'm a novice in this space with no formal training so any source or in depth explanations would be greatly appreciated.
Edit: As added bonus, is there an equation that handles rectangular cuboids?
 A: Denote the center of the cube as $(a,b,c)$, and let its sidelength be $L$.  Then the function 
$$
f(x,y,z) = \frac{L}{2} - \max(\lvert x-a \rvert, \lvert y - b \rvert, \lvert z - c \rvert)
$$ 
has the properties you describe.
Essentially, this measures how far each coordinate is from the center of the cube along that coordinate axis.  Outside the cube, each point has at least one coordinate of distance greater than $\frac{L}{2}$, points on the edges have at least one coordinate at distance $\frac{L}{2}$, and points on the interior have all coordinates within $\frac{L}{2}$ of the center.
A: The signed distance to the boundary function will always work. That is, if $\Omega$ is an open set in $\mathbb{R}^n$, define $f(x) = \inf_{p \in b\Omega}(|p-x|)$ if $x \in \overline\Omega$ and $f(x) = -\inf_{p \in b\Omega}(|p-x|)$ if $x \not\in \overline\Omega$.  
There may not be an easy "formula" in every case, but this is a function which works.  
In the case of the cube, it is not too hard to write down an explicit formula for the function I propose above.
A: whist not an exact cube
$$x^n+y^n+z^n=1$$
approximates a cube of side length 2, for large n.
An image for the shape with n=40

for a general rectangular cuboids, of length=$l$, width=$w$, and height=$h$,
the equation becomes
$$\left(\frac{2x}{l}\right)^n+\left(\frac{2y}{w}\right)^n+\left(\frac{2z}{h}\right)^n=1$$
hopefully that helps someone
