John Lerry wrote:How do I evaluate equality between different values (eg. between an int decimal and an int hexadecimal)?

This is not on the OCA exam (as mentioned in the explanation of the exercise as well).

So for completeness: it doesn't matter which number system (binary, octal, hexadecimal, decimal,...) is used to express the integral types (

`byte`,

`short`,

`int`, and

`long`). If for example an

`int` value expressed in binary and another

`long` value expressed in hexadecimal have the same value, they are equal; otherwise they are not. It's really that easy!

In order to calculate the value of such an integral type, you need to know which number system is used and calculate the value appropriately. And they all work very similar to the decimal number system you are familiar with, the only difference is the base (radix) of each number system is different (binary = 2, octal = 8, decimal = 10, hexadecimal = 16)

Sp let's start with the numbers from your example:

`78` -> decimal -> 7 * 10^1 + 8 * 10^0 = 7 * 10 + 8 * 1 = 78 (obviously)`0x4e` -> hexadecimal -> 4 * 16^1 + 14 * 16^0 = 4 * 16 + 14 * 1 = 78 (in hexadecimal: A=10, B=11, ..., F=15)
Another example:

`0b00100001` -> binary -> 0 * 2^7 + 0 * 2^6 + 1 * 2^5 + 0 * 2^4 + 0 * 2^3 + 0 * 2^2 + 0 * 2^1 + 1 * 2^0 = 0 * 128 + 0 * 64 + 1 * 32 + 0 * 16 + 0 * 8 + 0 * 4 + 0 * 2 + 1 * 1 = 33

And if you look for example to the

`Integer` class you'll see that the

`static` `parseInt`,

`toString` and

`valueOf` methods are overloaded and you can pass a radix. So you could for example decide to represent some number into the 35-base number system (which is used in

validating an IBAN number, a handy little known fact

). It's very similar to hexadecimal, you simply have much more letters which are valid: A = 10, B = 11, ..., Z = 35. An example:

So you can have some fun with your own name as well

Output:

`roel: 28 -> 611933 ; 31 -> 827876 ; 35 -> 1187536`
Hope it helps!

Kind regards,

Roel