I know that this isn't exactly a programming question, but it's related to the subject for me. How do you denote different numeral systems in just text? (By text I mean able to type at a proper speed and not copy-pasting it from another program.) For example if i have a number in base 2 how do I type it so others can understand that it's a base 2 number. On paper you can do something like (1001)2 where 2 is a small index. Is there some specific symbol that you have to type before the 2 so that others understand it as subscript? (Exponentiation uses the symbol ^ for this.) Or is it all just random and no standard exists in it?
The subscript 2 denotes a binary (i.e., base 2) number. Each digit in a binary number is called a bit. The number 1010110 is represented by 7 bits. Any number can be broken down this way, by finding all of the powers of 2 that add up to the number in question (in this case 26, 24, 22 and 21).
There are four main types of number systems: Binary number system (Base - 2) Octal number system (Base - 8) Decimal number system (Base - 10)
A convention in many programming languages is
0b1001
where the "b" indicates binary. Other conventions include starting with 0x for hexadecimal and starting with just 0 (followed by other digits) for octal.
For hex, you'd prefix it with 0x
.
0xFF
For Binary, a 0b
0b101
For Octal, a 0o
0o44
Alternatively, be more explicit?
dec(123)
hex(0AF)
bin(101)
oct(111)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With