1
00:00:00,940 --> 00:00:06,800
Hello and welcome back to Section four, lesson for no manipulation.

2
00:00:07,270 --> 00:00:12,730
So what we're going to talk about here as a follow up to the previous lesson, which was on just numbers

3
00:00:12,730 --> 00:00:16,630
and how those are formatted, we're going to talk about a number of different methods.

4
00:00:16,630 --> 00:00:21,070
You can chain on to the number library in order to verify numbers limits.

5
00:00:22,720 --> 00:00:24,420
OK, so let's take a look at this in code.

6
00:00:25,210 --> 00:00:26,170
First things first.

7
00:00:26,170 --> 00:00:32,530
We saw that we could take a string, so let's take a string like George.

8
00:00:33,730 --> 00:00:39,340
OK, now, if we try to turn this into a no, let's just see what happens.

9
00:00:41,820 --> 00:00:51,540
OK, it returns as not a number, but it has been modified by the no class, so let's try something

10
00:00:51,540 --> 00:00:51,900
else.

11
00:00:52,380 --> 00:00:59,400
Let's try let's try to turn five sixty seven.

12
00:01:00,980 --> 00:01:05,270
Into a number, we can see that that turns into a number just fine.

13
00:01:06,560 --> 00:01:12,090
And now we're going to try is a number is not yet.

14
00:01:13,640 --> 00:01:19,640
So what this checks is if this thing has been turned into a number, is it not a number?

15
00:01:20,180 --> 00:01:26,060
OK, so basically we're just checking to see if this is not a number of returns.

16
00:01:26,060 --> 00:01:30,710
A boolean value indicates whether the value is a is the reserved value, not a number.

17
00:01:31,610 --> 00:01:38,570
Unlike the global, this won't forcefully convert it to a no, so there's a difference here, basically,

18
00:01:38,580 --> 00:01:39,490
I'll show you the difference.

19
00:01:42,180 --> 00:01:44,450
So that checks and says this is false.

20
00:01:44,520 --> 00:01:52,860
OK, it's it's not a number, not a number, but if we did go here and get rid of this number class,

21
00:01:53,030 --> 00:01:58,530
just use the default is not a number and see that you could see that returns as true.

22
00:01:58,840 --> 00:01:59,180
OK.

23
00:02:03,070 --> 00:02:12,340
Now, if we were to do that here, this would also return as falls for this second value because it

24
00:02:12,340 --> 00:02:13,120
is a No.

25
00:02:15,680 --> 00:02:20,690
And if we wanted to return true, then we could do something like.

26
00:02:24,580 --> 00:02:33,010
We could do something like let's bring equal George and then we could no that street first.

27
00:02:42,020 --> 00:02:43,190
And then we could check

28
00:02:45,800 --> 00:02:48,760
whether that is not a number there.

29
00:02:49,310 --> 00:02:51,110
So now this second value here.

30
00:02:55,830 --> 00:03:01,740
It's going to verify that this is not a number, so it has been modified by the no class and it's still

31
00:03:01,740 --> 00:03:04,420
a string, George, so it's not a no.

32
00:03:05,310 --> 00:03:12,470
OK, it's converted it forcefully converted it to a number type, but it can't pass this as a number

33
00:03:12,470 --> 00:03:13,100
of value.

34
00:03:13,920 --> 00:03:17,040
So it is the reserve value, not a number at this point.

35
00:03:17,820 --> 00:03:18,150
OK.

36
00:03:20,130 --> 00:03:23,370
If we were just to consider log what that is, you could see it

37
00:03:27,420 --> 00:03:28,260
not a number.

38
00:03:28,800 --> 00:03:37,260
OK, so if it returns with this value, not a number, then number is any end will return as true.

39
00:03:38,970 --> 00:03:42,060
OK, so let's look at a number of other methods.

40
00:03:43,150 --> 00:03:46,140
Now we're going to do is finite, OK?

41
00:03:48,190 --> 00:03:49,510
So let's start with

42
00:03:52,750 --> 00:04:00,740
let's start with council log, but we're going to do is finite now finite means it just has an end.

43
00:04:00,740 --> 00:04:02,260
Does a number not like Pi?

44
00:04:02,290 --> 00:04:03,430
Pi doesn't have an end.

45
00:04:03,430 --> 00:04:05,920
It's it's this irrational number that goes on forever.

46
00:04:07,120 --> 00:04:11,400
This also let's just see what happens now.

47
00:04:11,410 --> 00:04:15,850
Ten divided by three is interesting because three is not a factor of 10.

48
00:04:16,160 --> 00:04:20,350
If you divide ten by three, you get three point three three three three three repeating.

49
00:04:21,850 --> 00:04:22,930
So let's see what it says.

50
00:04:25,030 --> 00:04:27,310
That returns as a finite value.

51
00:04:28,570 --> 00:04:35,020
So unlike the global is fine, it also it doesn't forcibly convert the parameter to a number, but because

52
00:04:35,020 --> 00:04:42,670
it understands that this actually is a rounded number because of how numbers work in JavaScript, if

53
00:04:42,670 --> 00:04:45,550
you print this out, it's going to round it.

54
00:04:45,910 --> 00:04:51,810
So it's not going to misunderstand that and it's going to treat it as a finite number.

55
00:04:52,240 --> 00:04:58,210
So just to see you're aware of that now, we can check if this is an integer and it should fail this

56
00:04:58,210 --> 00:05:07,510
one, an integer means it has no decimal values, so it has no period after the number and no trailing

57
00:05:07,510 --> 00:05:08,990
digits after a period.

58
00:05:09,400 --> 00:05:17,170
So if we tried this one, we get false, understandably, because ten divided by three is a decimal

59
00:05:17,170 --> 00:05:17,610
number.

60
00:05:18,310 --> 00:05:24,520
So it would be like it'd be the same as me just doing three three three three three three three three

61
00:05:24,520 --> 00:05:25,030
five.

62
00:05:26,410 --> 00:05:30,880
Or to be more specific, if you were to round it with proper rounding, you would be just that.

63
00:05:31,480 --> 00:05:36,100
OK, this is not an integer, this is a decimal value.

64
00:05:36,370 --> 00:05:37,780
And so it shows up as such.

65
00:05:37,970 --> 00:05:41,320
And you can also develop what is called a.

66
00:05:42,270 --> 00:05:51,800
Safe integer value and check is safe integer, and that's going to check for any value less than negative

67
00:05:51,840 --> 00:05:54,990
this number and greater than positive of that number.

68
00:05:55,950 --> 00:05:57,330
So what that's going to do?

69
00:05:59,790 --> 00:06:05,970
The reason for that is the number primitive class right here for primitive numbers in JavaScript just

70
00:06:05,970 --> 00:06:12,740
doesn't support double precision or rounding to numbers outside of this range right here.

71
00:06:13,680 --> 00:06:18,660
So you could check this number and see, hey, is this safe?

72
00:06:20,260 --> 00:06:22,870
It is good if you go on higher.

73
00:06:27,220 --> 00:06:28,880
It isn't OK.

74
00:06:30,160 --> 00:06:37,720
So any number in that range, and this corresponds with the value to to the fifty third power, minus

75
00:06:37,720 --> 00:06:38,050
one.

76
00:06:38,410 --> 00:06:44,950
So two to the fifty third power is not a safe integer because it is higher than that double precision.

77
00:06:44,950 --> 00:06:47,080
Number two to the fifty third power.

78
00:06:47,350 --> 00:06:55,420
OK, in bits that would be one higher than or one digit more in binary than the value represented by

79
00:06:55,420 --> 00:06:56,300
two to the fifty third.

80
00:06:56,680 --> 00:07:00,010
OK, so that will show you what is a safe integer.

81
00:07:00,220 --> 00:07:04,690
If you want to use numbers bigger than this, which you might want to do at some point, which is about

82
00:07:04,690 --> 00:07:05,950
nine quadrillion.

83
00:07:06,190 --> 00:07:09,690
So if you wanted to show this with commas, you could do this.

84
00:07:10,050 --> 00:07:14,830
Obviously, this won't be understood by the by the code, but that's what the number would look like

85
00:07:14,830 --> 00:07:15,400
with commas.

86
00:07:16,470 --> 00:07:22,210
OK, if you want to use numbers bigger than that, then there is a class you can use called Big Int.

87
00:07:23,110 --> 00:07:28,960
And that's that's something that will allow you to use numbers bigger than nine quadrillion.

88
00:07:30,010 --> 00:07:32,710
OK, a couple of other things you can do.

89
00:07:34,720 --> 00:07:37,960
You can do pass, float.

90
00:07:40,860 --> 00:07:42,090
And pass it.

91
00:07:48,010 --> 00:07:49,720
So if we pass it with

92
00:07:54,730 --> 00:08:00,250
we can say ninety nine balloons and we'll do the same thing here.

93
00:08:06,670 --> 00:08:14,350
So if you try with that, it's going to grab whatever numbers are at the beginning of that string and

94
00:08:14,350 --> 00:08:16,570
convert that string into a number.

95
00:08:17,480 --> 00:08:22,310
So it's just going to use whatever it can find, it's going to pass it, which means it's going to read

96
00:08:22,310 --> 00:08:26,030
through it and find the float, which is one type of a number.

97
00:08:26,480 --> 00:08:30,110
It's going to read through it and find the integer and then stop.

98
00:08:30,440 --> 00:08:32,640
OK, so this is very similar.

99
00:08:32,660 --> 00:08:36,760
This is basically the same as you can use this without the no class.

100
00:08:36,830 --> 00:08:41,150
You can just use it globally like this and do the same thing.

101
00:08:41,480 --> 00:08:46,750
And it's just going to grab the numbers from the beginning of the string and then go from there.

102
00:08:49,430 --> 00:08:57,610
But the difference here is that between these two is that past float will grab decimal values, OK,

103
00:08:58,490 --> 00:09:01,670
but pass it, as you can see, will not grab decimal values.

104
00:09:01,850 --> 00:09:06,620
So you get ninety nine point four or five out of ninety nine point four or five balloons and ninety

105
00:09:06,620 --> 00:09:09,790
nine out of ninety nine point four or five balloons with it.

106
00:09:09,890 --> 00:09:15,500
Because this is an integer integer, as I said, is a rounded number with no decimal values.

107
00:09:15,890 --> 00:09:20,000
A float is can be a decimal value with multiple decimals.

108
00:09:20,810 --> 00:09:24,320
OK, and that's it for number method's.

109
00:09:24,320 --> 00:09:28,670
There are a number of other ones you can take a look at, so check the resources we'll see in the next

110
00:09:28,670 --> 00:09:28,970
lesson.
