Fix if ... else if order to

As 1 is >= 0, the else if would never be used. I re-ordered, to check
against 1 before checking against >= 0.
Expose sprintf to the public api