Now we're on section for lesson three and we're going to talk about numbers, numbers are very basic
data type in JavaScript, lots of other programming languages, use other data types to represent different
numbers.
And we're talking about numbers like zero to infinity and negative numbers to some of the other data
types in other languages or decimals and floats into thirty two or sixty four.
These are 32 bit numbers, et cetera.
And so these are used to represent things like thirty seven or negative nine point twenty five or anything
else.
Now, when we start with strings, we can put a number inside of a string and it'll treat it as a string.
If it is if it can be interpreted as a no, we can use the no method.
And then turn that string into a number.
And then it just becomes a number so we can turn anything into a number if it if it'll work and numbers
can be written as decimal binary octal or hexadecimal, very different ways, and these represent different
bases, if you want to understand what that means.
As far as numbers go, binary is based to some numbers that are only zero or one.
Octal is base eight, and that's related to hexadecimal, which is base 16 and notice those are multiple
powers of two.
So two times two is four.
Four times two is eight.
Eight times two is sixteen.
Hexadecimal is actually used a lot in programming.
It's the basis for how we use a lot of our characters and special characters in language.
So when you type a character in on the computer or an emoji or something, those usually have a hexadecimal
reference that is interpreted by the computer as something that's part of a kind of this common lexicon
that computers use called Unicode.
So let's take a look at that and a little bit more about numbers in code.
OK, so we're here less than three.
Let's clear this out.
So numbers look like this.
That's a no,
this is a number right here,
we could do some math and we could get a resulting number.
OK.
So let's go ahead and see what that council does when we look at the three.
It does three point three, three three repeating and five, interestingly enough, JavaScript can do
some weird things at lowest digits, at four digits, and they'll be some interesting rounding happening.
And that has to do with the behavior of float's and to basically it's treating portions of the number
as fractions.
And as a result, it you can get some weird behavior, very, very tiny numbers in JavaScript.
OK, but these are various numbers, if we wanted to have a string, we could have a string like this.
OK, let's just say a string of five and that's going to be interpreted as a string.
Now, if we want to print that out.
Take a look at what that looks like.
As you can see, it doesn't treat it the same way, it treats it as a string.
But if we change this to a number first and then print it out, that turns it into a number.
If we turn it into a number and then print it out, it is interpreted now as a no.
OK, all right.
So now if you wanted to turn this back into a string, you could and there are a few.
The simple way to do that is to go straight.
String equals string.
That turns it back into history, another way that you can turn this into a no
is by doing pass int.
So you could just do pass it and what that's going to do is it's going to actually look for the numbers
at the beginning of the street and turn that into a number.
Cevdet.
Now, that's a no, and if we started with five, five, six, seven, five, two.
This would interpret this as five, five, six, seven as the number it's going to find the number at
the beginning and then stop there.
Interesting, huh?
Whereas if you try to do this with no, it would say, hey, that whole thing's not a no.
That's not a no and OK, you can learn a little bit more about numbers on the Amdocs who have the resources
in the project, and we'll see you in the next video.