Support Numbers in formatValue

and removed a reference to `this`, so that the function can be used stand-alone and not only as a method.