217k views
1 vote
In java, c or c++ code, when a number begins with a leading 0, what do you know about that number: (example: int zzz = 012;) in java, c or c++ code, when a number begins with a leading 0x, what do you know about that number: (example: int zzz =0x12;) in java, c or c++ code, when a number begins without a prefix, what do you know about that number: (example: int zzz =12;)

User Lakshmen
by
7.7k points

1 Answer

4 votes
A leading 0 denotes octal notation, so the digits 8 and 9 are not used.
In normal decimal notation 12 means 1*10+2, in octal, it means 1*8+2.

The leading 0x denotes hexadecimal notation, here the digits are extended with 6 letters, a through f. 0x12 means 1*16+2.

Without any prefix, we have normal decimal notation.
User Tom Dalton
by
8.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.