It’s just a syntax, just so the programmer feels more comfortable typing the number in the way the domain he’s treating usually works.
Most of the time it’s the same decimal. There are some typical problems when dealing with things from the computer that hexadecimal or binary is most suitable. For the application is a number, no matter how it was represented in the code. It’s just convenience, there’s nothing special. This has nothing to do with typing.
There is no such thing as converting everything to decimal, because the decimal itself is a representation. In fact we can say that everything is always converted to binary, which is how the computer understands it. But it’s binary even, it’s bits. What you see there in the code in binary notation is text with the characters 0
and 1
, it’s not a binary number, it’s just a textual representation.
C# did not adopt the octal that other languages usually have because it is practically not used anymore in practice and usually generates confusion. There are methods that convert texts to this, or from this base.
Then in Hexadecimal you can represent with the prefix 0x
(ex.: 0xD08C
) or in binary with prefix 0b
(ex.: 0b1001_1101
), decimal is the default and need nothing extra.
Note that it is possible to use tab wherever you want in any representation.
You can represent the same number in several ways, now I will represent the number 3:
Just out of curiosity: most languages use only base 10 and base 16, some allow base 2 and/or 8 as well. Boolfuck only works on the basis of 2 and Java2k uses numerical basis only 11.
– Oralista de Sistemas