Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to denote different numeral systems while typing?

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?

like image 208
Johnny Avatar asked Sep 21 '10 19:09

Johnny


People also ask

How do you denote binary numbers?

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).

How many numbering systems are there in the world?

There are four main types of number systems: Binary number system (Base - 2) Octal number system (Base - 8) Decimal number system (Base - 10)


2 Answers

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.

like image 104
Jacob Mattison Avatar answered Jan 03 '23 00:01

Jacob Mattison


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)
like image 37
CaffGeek Avatar answered Jan 02 '23 23:01

CaffGeek