# 35 Integer Literals Octal and decimal – Javascript

Last updated on July 13th, 2020 at 11:44 am.

This video is taken from the full course that will teach you HTML, CSS, Programming concepts and Javascript .

Transcript :

Hi, and welcome back.

So in the last video we intimated things about integer literals and we said something small about decimal and the hexadecimal.

Let’s go one step at a time and see how, how we can represent each of these different number systems in our JavaScript code.

This one is very easy, how to represent a decimal number in your code.

As long as you have any digit, one or more digits without a leading zero, you know 1, 2, may be the numbers is 100, maybe the number is 109, maybe the number is 221.

As long as it doesn’t have a leading zero in front of it and we’re going to see why this leading zero is a very important thing not to have.

So, you can represent a decimal number.

So if I say 12, let’s start with a number like 12.

Then we say display, you see it just gives us 12.

So you can do different things with this.

You can multiply it with a different number.

You can add it to another number.

You can multiply it by itself, add it to itself.

The important thing, no leading zero to represent a decimal integer literal.

And then let’s go to octal.

This is where the leading zero thing is very important.

So you can see here this one, the octal, to represent an octal number in your code.

This one has a leading zero or a leading zero with an ‘o’ or a leading zero with a capital ‘O’.

So this is a small ‘o’, and this is a capital ‘O’.

And it can only contain digits from 0-7.

So let’s see why this and this can be confusing.

So if I come back here and this one is 12 right.

What if I come here and I add zero at the front of it.

If I add zero at the front of it, let’s see the value that we get.

So if I display, you see that tells us that the number there being held is 10.

So that means that this was interpreted as an octal number.

So an octal number, it will have a number from 0-7 and it can start with a zero or a zero and a small zero or a zero and a capital ‘O’ I mean.

Not a zero but a ‘O’.

So you see, this is very important.

So you can see why this is so important.

If you were doing some kind of a computation and you added a zero in front of a number, it could easily have been interpreted as an octal number.

So just to recap, we’ve seen that a decimal number, it can be any number one or more digits with no leading zero.

So, you have to note it’s a digit.

It only contains numbers from 0-9.

It can only contain digits from 0-9 with no leading zero.

So that is a decimal number.

And then this one, octal number.

An octal number, you can represent it with a leading zero or a zero and a small ‘o’ or a zero and a capital ‘O’ and can only contain digits from 0-7.

So like we saw with this one.

So it can also be like that.

And if we try to run that, we say display.

You see, it gives us 10.

That’s it for this video.

Let’s continue in the next video and let’s continue looking at integer literals and how they can be represented in the different numeral systems.

So I’ll see you in the next video.

Click the button below to watch this full course:

### Recommended VPS Providers

Find out the VPS providers I recommend.

Close me!