Fix num2hex()'s handling of zero

See #7242.