1
00:00:01,270 --> 00:00:09,340
Floating points, numbers, floating point types, store approximations of real numbers, which in our

2
00:00:09,340 --> 00:00:14,230
case can be defined as any number that has a decimal point.

3
00:00:14,230 --> 00:00:22,240
And the fractional part, such as 0.333, three or 98.6 or P.

4
00:00:22,450 --> 00:00:29,230
Although it's not possible to represent an arbitrary real number exactly in computer memory, but it's

5
00:00:29,230 --> 00:00:32,170
possible to store an approximation.

6
00:00:32,170 --> 00:00:40,480
So if it seems hard to believe, just think about magic number P, which has infinitely many digits

7
00:00:40,720 --> 00:00:43,270
with free computer memory.

8
00:00:43,330 --> 00:00:47,140
How could you possibly represent infinitely many digits?

9
00:00:47,710 --> 00:00:56,610
As with all types, floating point types take up a infinite amount of memory, which is called the types

10
00:00:56,620 --> 00:00:58,150
precision.

11
00:00:58,630 --> 00:01:04,150
The more precision floating point type has, the more accurate it will be.

12
00:01:04,180 --> 00:01:06,460
Approximation a real number.

13
00:01:06,820 --> 00:01:13,140
C++ offer three levels of precision for approximations.

14
00:01:13,150 --> 00:01:15,490
The first level is plot.

15
00:01:16,340 --> 00:01:20,320
The second double and the three long double.

16
00:01:20,330 --> 00:01:27,860
So these levels mean of course, these are the imaginary levels, but this is the single precision.

17
00:01:29,700 --> 00:01:33,720
We have the double for double precision.

18
00:01:34,770 --> 00:01:36,660
Double precision.

19
00:01:37,110 --> 00:01:44,520
And the next we have the long double for extended precision.

20
00:01:46,970 --> 00:01:48,260
At precision.

21
00:01:48,470 --> 00:01:56,810
So as with integer types, each floating point representation depends on implementation.

22
00:01:57,590 --> 00:02:06,170
The section won't go into detail about floating point tiles, but note that there is substantial nuance

23
00:02:06,170 --> 00:02:08,240
involved in these implementations.

24
00:02:09,440 --> 00:02:12,840
On major desktop operating system.

25
00:02:12,860 --> 00:02:20,480
The float level usually has four bytes of precision.

26
00:02:20,840 --> 00:02:21,350
Here.

27
00:02:23,740 --> 00:02:24,940
Poor bites.

28
00:02:26,600 --> 00:02:37,250
The double and long hair levels usually usually have eight bytes, eight bytes and long double eight

29
00:02:37,250 --> 00:02:39,620
bytes eight bytes.

30
00:02:40,900 --> 00:02:44,200
So most users are not involved in scientific computing.

31
00:02:44,200 --> 00:02:50,740
Applications can safely ignore the details of floating point representation in such cases.

32
00:02:50,770 --> 00:02:56,260
A good general rule is to use double.

33
00:02:58,550 --> 00:03:01,950
For tools who cannot safely ignore the details.

34
00:03:01,970 --> 00:03:05,990
Look at the floating point specifications relevant to your hardware platform.

35
00:03:07,930 --> 00:03:13,090
And let's go to floating point literals.

36
00:03:13,360 --> 00:03:14,980
Floating point Literals.

37
00:03:16,360 --> 00:03:17,010
They are.

38
00:03:23,170 --> 00:03:25,390
Floating point laterals.

39
00:03:28,820 --> 00:03:29,270
Yes.

40
00:03:37,610 --> 00:03:38,080
We are.

41
00:03:38,480 --> 00:03:39,350
And yes.

42
00:03:40,130 --> 00:03:44,370
The floating point literals are double precision by default.

43
00:03:44,390 --> 00:03:52,100
If you need a single position, use an F or uppercase F suffix for extended precision.

44
00:03:52,100 --> 00:03:56,960
Use L or uppercase L as I will show here.

45
00:03:56,960 --> 00:04:08,150
Float A, for example, 0.1 F, double B, for example 0.2 just a 2 to 0.2.

46
00:04:08,180 --> 00:04:11,270
We don't need to add any literal or suffix.

47
00:04:11,390 --> 00:04:18,830
And lastly, long double long double C equals 0.3 L.

48
00:04:20,350 --> 00:04:24,340
As you can see, we used the uppercase L and uppercase F.

49
00:04:24,910 --> 00:04:28,810
Actually, let's change the comment here so you can see the codes.

50
00:04:30,000 --> 00:04:30,480
So.

51
00:04:33,180 --> 00:04:36,960
And you can also use the scientific notation in literals.

52
00:04:36,960 --> 00:04:37,590
Here.

53
00:04:38,620 --> 00:04:38,970
Here.

54
00:04:39,000 --> 00:04:39,720
Double.

55
00:04:40,950 --> 00:04:42,570
For example, Planck's.

56
00:04:43,940 --> 00:04:45,170
Banks constant.

57
00:04:46,850 --> 00:04:50,210
The Planck's constant.

58
00:04:50,300 --> 00:04:52,610
The Planck's constant is six point.

59
00:04:53,590 --> 00:05:02,260
626074004 and E -34.

60
00:05:03,220 --> 00:05:06,670
So you might be wondering what is this though?

61
00:05:06,670 --> 00:05:14,950
So no space here are permitted between the significant the base and the suffix, the potential portion

62
00:05:15,160 --> 00:05:17,440
and the E for 34.

63
00:05:18,840 --> 00:05:29,670
So that's why we didn't use any suffixes or like any space or literal to use for separation of these

64
00:05:29,670 --> 00:05:32,430
codes, these values.

65
00:05:32,550 --> 00:05:39,960
So the floating point format specifiers, we have format specifiers for printing the these numbers on

66
00:05:39,960 --> 00:05:40,530
console.

67
00:05:40,920 --> 00:05:48,270
So the format specified for F displays a float with decimal digits.

68
00:05:48,270 --> 00:05:51,180
Whereas here e.

69
00:05:52,010 --> 00:05:54,590
This place the same number in scientific notation.

70
00:05:54,920 --> 00:06:04,010
You can let printf decide which of these to to use with the g format specified which selects the more

71
00:06:04,010 --> 00:06:07,970
compact of E or F for double.

72
00:06:07,970 --> 00:06:18,830
You simply depend on l lowercase l here to describe desired specifiers, so for long double you prepend

73
00:06:18,830 --> 00:06:21,050
an uppercase l.

74
00:06:21,050 --> 00:06:27,110
For example, if you want to want a double with decimal digits, you will specify l l.

75
00:06:27,110 --> 00:06:31,520
F l or l.

76
00:06:31,520 --> 00:06:32,610
G near.

77
00:06:34,280 --> 00:06:37,400
Well in that comment here double.

78
00:06:38,720 --> 00:06:39,500
With.

79
00:06:41,920 --> 00:06:43,090
Decimal digits.

80
00:06:44,860 --> 00:06:45,310
Yes.

81
00:06:46,450 --> 00:06:47,350
And the.

82
00:06:48,920 --> 00:06:59,670
You will test fire l f, l, or l g here with decimal digits, but for a long double you will you will

83
00:06:59,670 --> 00:07:11,610
specify l lone double double eight decimal digits f or long double.

84
00:07:11,760 --> 00:07:21,390
You need to use the uppercase L on the case F and the same uppercase l.

85
00:07:21,630 --> 00:07:23,730
E or.

86
00:07:25,760 --> 00:07:26,810
L Jim.

87
00:07:27,560 --> 00:07:37,280
So let's write an example code for this and start and compile and run the program, which I will show

88
00:07:37,280 --> 00:07:42,860
you how this format specifiers work on tables.

89
00:07:43,340 --> 00:07:46,720
So we have the main command.

90
00:07:46,880 --> 00:07:47,510
Main.

91
00:07:48,810 --> 00:07:49,740
Function here.

92
00:07:51,290 --> 00:07:55,280
So we can freely use this as our code.

93
00:07:55,520 --> 00:07:56,630
So double.

94
00:07:57,470 --> 00:08:00,770
And here, 6.0.

95
00:08:02,390 --> 00:08:13,700
221409e 23 which I will explain all of these codes later after compiling and print f.

96
00:08:16,870 --> 00:08:19,630
For example, Avogadro's number.

97
00:08:23,510 --> 00:08:25,130
Number is.

98
00:08:25,130 --> 00:08:27,860
I will explain all of these quotes, of course.

99
00:08:27,860 --> 00:08:28,370
Here.

100
00:08:28,760 --> 00:08:29,090
L.

101
00:08:29,120 --> 00:08:29,720
E.

102
00:08:30,760 --> 00:08:31,720
I'll have.

103
00:08:32,490 --> 00:08:43,820
LG and New line Mir, then I will give the three three times the same number, but with different format

104
00:08:43,950 --> 00:08:46,130
specifiers and e.

105
00:08:46,140 --> 00:08:46,710
N.

106
00:08:47,130 --> 00:08:47,760
M.

107
00:08:48,760 --> 00:08:50,470
Here and.

108
00:08:51,430 --> 00:08:52,830
Was this court here.

109
00:08:52,840 --> 00:09:01,510
And lastly, let's create the float number each P 9.9..

110
00:09:02,760 --> 00:09:04,560
76.

111
00:09:06,010 --> 00:09:06,520
Here.

112
00:09:06,880 --> 00:09:08,290
Let's print.

113
00:09:09,010 --> 00:09:10,510
Turned f.

114
00:09:12,490 --> 00:09:13,480
Hogwarts.

115
00:09:16,450 --> 00:09:17,230
Platform.

116
00:09:20,220 --> 00:09:20,430
G.

117
00:09:21,240 --> 00:09:22,410
And e.

118
00:09:22,830 --> 00:09:23,430
F.

119
00:09:24,120 --> 00:09:24,690
G.

120
00:09:25,020 --> 00:09:28,080
New line give this use.

121
00:09:28,080 --> 00:09:31,890
This format uses the HP number with different format.

122
00:09:31,890 --> 00:09:39,390
Specifies three times HP, HP, HP and so.

123
00:09:45,010 --> 00:09:46,830
Imprint after.

124
00:09:50,000 --> 00:09:54,350
And let's finally compile this code here.

125
00:09:54,480 --> 00:09:55,240
Clear.

126
00:09:56,720 --> 00:09:57,050
Yes.

127
00:09:57,050 --> 00:10:00,000
Assuming that zip code is compiled.

128
00:10:00,020 --> 00:10:02,000
Use the e a that.

129
00:10:02,960 --> 00:10:03,830
Let's save this code.

130
00:10:03,830 --> 00:10:05,090
Firstly with control.

131
00:10:05,090 --> 00:10:06,860
Save and let's compile it again.

132
00:10:07,820 --> 00:10:08,450
Use this code.

133
00:10:08,450 --> 00:10:08,990
So.

134
00:10:10,260 --> 00:10:10,980
Okay.

135
00:10:12,390 --> 00:10:13,270
Also.

136
00:10:14,910 --> 00:10:15,450
Yes.

137
00:10:15,510 --> 00:10:19,680
So as you can see here, let me.

138
00:10:20,280 --> 00:10:20,820
Okay.

139
00:10:20,910 --> 00:10:31,380
So as you can see here, the first we did the program declares a double here, double called RN.

140
00:10:31,980 --> 00:10:35,880
The format specified for the format specified l.

141
00:10:35,910 --> 00:10:36,510
E.

142
00:10:37,430 --> 00:10:41,630
Gives you a scientific notation of these numbers.

143
00:10:41,630 --> 00:10:44,540
So let's see what this first.

144
00:10:45,450 --> 00:10:46,140
Gave us.

145
00:10:46,260 --> 00:10:49,500
This is the scientific notation which we used as l.

146
00:10:49,530 --> 00:10:49,980
E.

147
00:10:51,360 --> 00:10:52,500
This is scientific notation.

148
00:10:52,770 --> 00:10:54,030
The program gives us.

149
00:10:54,420 --> 00:10:56,880
And the second way did fear.

150
00:11:01,010 --> 00:11:07,340
Gives the decimal representation of this e n number.

151
00:11:07,940 --> 00:11:13,250
As you can see, this gave us the very long decimal representation of this number.

152
00:11:14,150 --> 00:11:16,370
The last one, LG.

153
00:11:17,350 --> 00:11:24,820
Specify for the chooses the scientific notation of these, as you can see here.

154
00:11:27,050 --> 00:11:33,080
This notation gave us almost the same E and number so.

155
00:11:34,380 --> 00:11:41,390
And here we as you know, we created the plot called each p.

156
00:11:41,850 --> 00:11:49,770
This produce similar printf output using the e and F specifiers as you can see here.

157
00:11:53,260 --> 00:11:55,150
But the format specified.

158
00:11:55,150 --> 00:11:56,260
G here.

159
00:11:56,260 --> 00:11:57,160
Format specified.

160
00:11:57,160 --> 00:11:57,940
G here.

161
00:11:58,750 --> 00:12:05,880
Decided to provide the decimal representation of 9.76.

162
00:12:06,300 --> 00:12:08,840
Rather than the scientific notation as a general.

163
00:12:09,840 --> 00:12:11,100
Use the G.

164
00:12:12,050 --> 00:12:15,500
Print floating point types.

165
00:12:17,920 --> 00:12:21,610
The next lecture will be about the character types.

166
00:12:21,970 --> 00:12:24,130
And I'm waiting you in the next lecture.
