Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I am wondering which numeral system different programmers are using, or would use if their language has support for them. As an example, in C++ we can use:

When working with bitmask, I am using hexadecimal but would sometimes want to be able to express binary numbers directly. I know some programming language support it with 0b syntax (e.g. 0b11111111).

Is there any other numeric system useful in some computer science domain (e.g. cryptography, codecs, 3D graphics, etc)?

share|improve this question
There are extensions to decimal like 1L or 1UL. Then there floating points like 1.1 or 1.1e-15. – ott-- Nov 3 '12 at 18:12
Did you forget base 256, which is how integers are most often represented in the computer, as far as the program is concerned? I.e. the whole "endianness" thing is about which way around numbers are represented in base 256. – Ambroz Bizjak Nov 4 '12 at 0:08

2 Answers 2

up vote 4 down vote accepted

For the sake of theoretical computer science, the branch of abstract mathematics, everything is either done conveniently in base10, which we normally operate in, or base2, because it's the simplest to reason about.

In the more general sense of computer science, meaning the things you're likely to study for a CS degree, the situation is very similar. Pretty much everything will simply be done in base10. The biggest reason you'll work with base2 is architecture classes when you're learning the internal representation of numbers in a CPU & how they're operated on. Base8 and base16 might come up if you find yourself working in assembly or low-level OS operations.

If you get down to it, binary, octal and hex, all being powers of two, are essentially equivalent - they're convenient ways to represent a sequence of bits. As time passes, there become fewer reasons to bother with them for general purpose computing. Using bitmasks (or the equivalent hex codes) was an essential tool in saving memory when you're dealing with a system that only has a few KB of memory but in an era where desktop icons can be over a megabyte, it's seldom worth the hassle. Obviously, there's still people writing low-level hardware interfaces, network services & doing embedded development but most programmers are increasingly isolated from that by layers of abstraction.

I'm not saying it's bad to learn them - it can be quite useful to be familiar with them (for example, Unix file permissions still use Octal) but don't expect to be using them every day.

share|improve this answer

Minutes and seconds use base60, base64 encoding uses base64 (doh), radian angles use Pi as base, us stocks used to have weird fractions instead of decimals, dates have irregular base (different amount of days in month) and so on.

In general - any system can prove useful under certain conditions, but most often than not it is dictated by domain traditions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.