This fixes two bugs reported in #121795 and adds regression tests. Specifically, these bugs are in the base detection mechanism. The first bug is that the out parameter isn't set when the stream only contains zero and after that is the end of the stream. The second one is that we don't consider `0` to be a number, and instead we only parse it as the start of an octal literal.