# How to represent positive integers in binary

When we work with computers, one of the first things we will need is to store integers (and that was needed back in the day).

Remember that integers include:

• Positive natural numbers (1, 2, 3…)
• Zero (0, here a zero, look how nice, all round)
• Negative numbers (-1, -2, -3…)

But as we know, internally our computer only knows numbers in binary system. So we will have to see how we can represent our numbers in this system.

For now, in this article we will see how to encode positive integers and zero (in the next article we will talk about negative numbers).

## Representation of positive integers in binary

The representation of positive integers is the simplest of all. It really doesn’t have much mystery, it’s simply counting upwards (it doesn’t matter if it’s Base 2, Base 10, or Base “whatever”).

But let’s write it down in some guidelines:

• Zero is zero, in any base
• From there, we increment based on the base we are working with

For example, here are the first 16 positive numbers represented, counting zero, represented in Decimal and Binary systems:

DecimalBinary
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001
101010
111011
121100
131101
141110
151111

To change from one to the other we just have to change the base, as we saw in this article.

## How much is a binary number worth?

Importantly, I want to make a reflection that I will not tire of repeating. Do not confuse a number with its representation.

I repeat this a lot because, if you understand that, you will avoid many problems and mistakes in understanding all of this

When you see a number in binary system, for example:

``10011001``

How much is that set of bits worth? You don’t know, it means nothing until you tell me what it represents.

So, it will be different things if:

• It represents an integer
• It represents a number with positives and negatives
• It represents a fractional number
• It represents something else …

That said, if you don’t tell me anything, the logical assumption is that you are referring to a positive number, because it’s the simplest. So the previous number is worth 153, if you don’t tell me anything else.