1
00:00:00,060 --> 00:00:06,270
Now we're on section for lesson three and we're going to talk about numbers, numbers are very basic

2
00:00:06,270 --> 00:00:11,670
data type in JavaScript, lots of other programming languages, use other data types to represent different

3
00:00:11,670 --> 00:00:12,060
numbers.

4
00:00:12,060 --> 00:00:17,550
And we're talking about numbers like zero to infinity and negative numbers to some of the other data

5
00:00:17,550 --> 00:00:23,470
types in other languages or decimals and floats into thirty two or sixty four.

6
00:00:23,490 --> 00:00:25,580
These are 32 bit numbers, et cetera.

7
00:00:26,460 --> 00:00:31,380
And so these are used to represent things like thirty seven or negative nine point twenty five or anything

8
00:00:31,380 --> 00:00:31,650
else.

9
00:00:32,660 --> 00:00:38,180
Now, when we start with strings, we can put a number inside of a string and it'll treat it as a string.

10
00:00:39,320 --> 00:00:43,970
If it is if it can be interpreted as a no, we can use the no method.

11
00:00:44,990 --> 00:00:47,210
And then turn that string into a number.

12
00:00:48,120 --> 00:00:55,980
And then it just becomes a number so we can turn anything into a number if it if it'll work and numbers

13
00:00:55,980 --> 00:01:02,130
can be written as decimal binary octal or hexadecimal, very different ways, and these represent different

14
00:01:02,130 --> 00:01:05,250
bases, if you want to understand what that means.

15
00:01:05,250 --> 00:01:10,650
As far as numbers go, binary is based to some numbers that are only zero or one.

16
00:01:11,670 --> 00:01:20,310
Octal is base eight, and that's related to hexadecimal, which is base 16 and notice those are multiple

17
00:01:20,310 --> 00:01:21,140
powers of two.

18
00:01:21,150 --> 00:01:22,980
So two times two is four.

19
00:01:23,520 --> 00:01:24,750
Four times two is eight.

20
00:01:25,440 --> 00:01:26,790
Eight times two is sixteen.

21
00:01:27,420 --> 00:01:30,480
Hexadecimal is actually used a lot in programming.

22
00:01:31,170 --> 00:01:37,860
It's the basis for how we use a lot of our characters and special characters in language.

23
00:01:38,310 --> 00:01:44,340
So when you type a character in on the computer or an emoji or something, those usually have a hexadecimal

24
00:01:44,340 --> 00:01:52,320
reference that is interpreted by the computer as something that's part of a kind of this common lexicon

25
00:01:52,320 --> 00:01:54,210
that computers use called Unicode.

26
00:01:55,580 --> 00:01:59,900
So let's take a look at that and a little bit more about numbers in code.

27
00:02:00,400 --> 00:02:02,240
OK, so we're here less than three.

28
00:02:03,080 --> 00:02:04,420
Let's clear this out.

29
00:02:08,730 --> 00:02:13,020
So numbers look like this.

30
00:02:13,740 --> 00:02:14,790
That's a no,

31
00:02:18,390 --> 00:02:20,160
this is a number right here,

32
00:02:23,910 --> 00:02:28,080
we could do some math and we could get a resulting number.

33
00:02:30,160 --> 00:02:30,570
OK.

34
00:02:31,830 --> 00:02:38,340
So let's go ahead and see what that council does when we look at the three.

35
00:02:45,060 --> 00:02:51,570
It does three point three, three three repeating and five, interestingly enough, JavaScript can do

36
00:02:51,570 --> 00:02:58,590
some weird things at lowest digits, at four digits, and they'll be some interesting rounding happening.

37
00:02:59,190 --> 00:03:10,680
And that has to do with the behavior of float's and to basically it's treating portions of the number

38
00:03:10,680 --> 00:03:11,550
as fractions.

39
00:03:12,030 --> 00:03:17,940
And as a result, it you can get some weird behavior, very, very tiny numbers in JavaScript.

40
00:03:19,310 --> 00:03:26,060
OK, but these are various numbers, if we wanted to have a string, we could have a string like this.

41
00:03:28,100 --> 00:03:35,700
OK, let's just say a string of five and that's going to be interpreted as a string.

42
00:03:35,720 --> 00:03:38,600
Now, if we want to print that out.

43
00:03:42,610 --> 00:03:44,800
Take a look at what that looks like.

44
00:03:46,430 --> 00:03:50,300
As you can see, it doesn't treat it the same way, it treats it as a string.

45
00:03:50,300 --> 00:04:03,110
But if we change this to a number first and then print it out, that turns it into a number.

46
00:04:17,130 --> 00:04:24,720
If we turn it into a number and then print it out, it is interpreted now as a no.

47
00:04:26,040 --> 00:04:27,210
OK, all right.

48
00:04:27,210 --> 00:04:32,430
So now if you wanted to turn this back into a string, you could and there are a few.

49
00:04:33,150 --> 00:04:38,340
The simple way to do that is to go straight.

50
00:04:41,700 --> 00:04:44,860
String equals string.

51
00:04:50,230 --> 00:04:55,640
That turns it back into history, another way that you can turn this into a no

52
00:04:58,310 --> 00:05:01,460
is by doing pass int.

53
00:05:03,730 --> 00:05:09,610
So you could just do pass it and what that's going to do is it's going to actually look for the numbers

54
00:05:09,610 --> 00:05:12,790
at the beginning of the street and turn that into a number.

55
00:05:15,060 --> 00:05:15,750
Cevdet.

56
00:05:16,660 --> 00:05:24,430
Now, that's a no, and if we started with five, five, six, seven, five, two.

57
00:05:26,090 --> 00:05:32,300
This would interpret this as five, five, six, seven as the number it's going to find the number at

58
00:05:32,300 --> 00:05:34,390
the beginning and then stop there.

59
00:05:35,410 --> 00:05:36,160
Interesting, huh?

60
00:05:37,300 --> 00:05:42,370
Whereas if you try to do this with no, it would say, hey, that whole thing's not a no.

61
00:05:44,590 --> 00:05:53,920
That's not a no and OK, you can learn a little bit more about numbers on the Amdocs who have the resources

62
00:05:53,920 --> 00:05:56,410
in the project, and we'll see you in the next video.
