The string must begin with '0x' for hexadecimal strings or '0' (zero) for octal strings. If exp is invalid, int returns nil as a default value if not otherwise specified.
If you prefix it with a 0, it will be evaluated as octal. There is no 9 or 8 in octal, since 8 dec is 10 oct.
To be fair I found it a bit weird when I first read about it as well. I think having h and o prefixes would have been clearer, but I guess as long as one knows about it it's not too hard to avoid it as you have shown in your post.