Shadowwynd

Member Since: November 26, 2010

Country: United States

Profile

Role

Assistive Technology Designer

Spoken Languages

English

Programming Languages

C/C++, Basic, Java, Python, x86 assembler

Universities

University of Tennessee at Chattanooga

  • Tutorial - Number System Conversions | about 3 years ago

    0b and 0x are very widely-held convention to distinguish the base you are using. Many programming languages (C, C++, Python, etc.) and much of computer science in general follow this convention. <br />
    <br />
    For instance (you are on your private island or something), you could write numbers as 10101 (base:binary) or 66 (base:hexadecimal). The immediate problem is that as you read left to right, you automatically see 10,101 (decimal) or 66 (decimal) - neither one of which is right.<br />
    <br />
    To distinguish, a prefix is added because your eyes see the prefix first. 0x is used as a prefix for hex notation and 0b is for binary. The examples I listed then become 0b10101 or 0x66.<br />
    <br />
    If you see a number without a prefix, assume base 10 (decimal). 0b is binary (b for binary). 0x is hex (it has an x in it)<br />
    <br />
    Octal (base 8) has BAD prefix notation but fortunately octal is only rarely encountered. Octal is just prefixed with a zero. This is highly ambiguous and VERY prone to misreading, confusion, and error. For instance, if I wrote the number 067, the most common interpretation is to strip the zeroes in front, thus giving a decimal 67. If we were talking octal, this leading zero would mean it would be an octal number.<br />
    <br />
    The number fifty-five in binary, octal, decimal, and hex:<br />
    <br />
    0b110111 = 067 = 55 = 0x37

No public wish lists :(