decimalbitliteralsoctal

Why is 0128 in octal considered not valid to convert in decimal?


I'm practicing for an exam and I'm doing literals, what came up to me was a question that asked to convert 0128 octal into a decimal , so I also have the solution for this question which is that it has too many bits to be considered an octal so it can't be converted into a decimal as well, but the motivation of it is not described.

Do you know why because I'm trying to figure it out, but I couldn't find any answer yet.


Solution

  • One answer is "invalid input" but a different answer might be to consider the input as "012" with the first non-octal character acting as the termination of the octal number. The answer would therefore be 10 decimal.