1 00:00:00,800 --> 00:00:02,030 - [Narrator] Next let's take a look 2 00:00:02,030 --> 00:00:04,410 at some numeric formatting. 3 00:00:04,410 --> 00:00:07,530 Now, normally when you display a positive number 4 00:00:07,530 --> 00:00:10,280 it's not preceded by a plus sign 5 00:00:10,280 --> 00:00:12,290 and when you display a negative number 6 00:00:12,290 --> 00:00:14,910 it is preceded by a minus sign. 7 00:00:14,910 --> 00:00:17,690 So let's take a look at how you can force 8 00:00:17,690 --> 00:00:21,500 a positive number to be preceded by a plus sign. 9 00:00:21,500 --> 00:00:24,910 So here we have the number 27 being formatted 10 00:00:24,910 --> 00:00:27,200 in a field of 10 as an integer 11 00:00:27,200 --> 00:00:29,850 by putting the plus sign before the field width 12 00:00:29,850 --> 00:00:31,960 we're saying we would like it to always 13 00:00:31,960 --> 00:00:34,980 display a plus sign if in fact the value 14 00:00:34,980 --> 00:00:36,650 is a positive number. 15 00:00:36,650 --> 00:00:40,910 So in this case we get the formatted string plus 27. 16 00:00:40,910 --> 00:00:45,260 Now, there is also a capability to fill in 17 00:00:45,260 --> 00:00:48,160 the extra spaces with a leading zero 18 00:00:48,160 --> 00:00:50,650 if that's something that would be helpful for you, 19 00:00:50,650 --> 00:00:53,400 so in that case the leading zeroes 20 00:00:53,400 --> 00:00:56,840 would come in inbetween the plus sign and the number, 21 00:00:56,840 --> 00:01:00,180 so as you can see here we've gone ahead, 22 00:01:00,180 --> 00:01:01,860 and actually we haven't done it yet, 23 00:01:01,860 --> 00:01:03,580 let's go ahead and do it, there we go, 24 00:01:03,580 --> 00:01:06,950 we've put in a zero before the 10d 25 00:01:06,950 --> 00:01:09,700 so this is two flags, plus and zero, 26 00:01:09,700 --> 00:01:13,010 and then a field width of 10 indicating 27 00:01:13,010 --> 00:01:16,100 that we're going to format an integer in that field width. 28 00:01:16,100 --> 00:01:18,570 So in this case we'll get a plus sign, 29 00:01:18,570 --> 00:01:21,560 a bunch of zeroes, and then the number 27 30 00:01:21,560 --> 00:01:24,120 in our formatted result. 31 00:01:24,120 --> 00:01:27,020 You also have the ability to indicate 32 00:01:27,020 --> 00:01:29,590 that a space character should appear 33 00:01:29,590 --> 00:01:32,960 wherever the plus sign would normally appear. 34 00:01:32,960 --> 00:01:35,540 So here we have a print statement 35 00:01:35,540 --> 00:01:39,000 that's going to display three separate formatted values, 36 00:01:39,000 --> 00:01:42,100 the value 27 simply as an integer, 37 00:01:42,100 --> 00:01:44,700 the value 27 with a space character 38 00:01:44,700 --> 00:01:46,350 where the plus sign should go, 39 00:01:46,350 --> 00:01:49,680 and we're also going to show you a negative 27 value, 40 00:01:49,680 --> 00:01:52,730 and we put in the space here but that's not going to 41 00:01:52,730 --> 00:01:55,870 have an effect on the minus 27 value. 42 00:01:55,870 --> 00:01:57,990 So in the second case where we said 43 00:01:57,990 --> 00:02:01,120 to put in that space, that's where the plus sign 44 00:02:01,120 --> 00:02:03,160 would normally appear if in fact 45 00:02:03,160 --> 00:02:06,700 we told it to display one, and that enables us 46 00:02:06,700 --> 00:02:10,060 to basically align these two numeric values 47 00:02:10,060 --> 00:02:12,540 in this particular case. 48 00:02:12,540 --> 00:02:15,180 Now, separately we have seen this previously 49 00:02:15,180 --> 00:02:19,480 but I do want to iterate, or revisit it rather, 50 00:02:19,480 --> 00:02:22,720 so here we're using the comma specifier 51 00:02:22,720 --> 00:02:25,020 which is for grouping digits, 52 00:02:25,020 --> 00:02:27,490 and in this case we're formatting an integer 53 00:02:27,490 --> 00:02:30,600 with the thousands separator, so you can see 54 00:02:30,600 --> 00:02:34,170 we get the last three digits, the comma, 55 00:02:34,170 --> 00:02:35,700 the next three digits, the comma, 56 00:02:35,700 --> 00:02:38,210 and the first two digits, and of course 57 00:02:38,210 --> 00:02:41,090 we can use that with floating point values as well, 58 00:02:41,090 --> 00:02:44,210 so here we're formatting a value with two digits 59 00:02:44,210 --> 00:02:45,530 to the right of the decimal point 60 00:02:45,530 --> 00:02:47,573 but we also have that comma flag 61 00:02:47,573 --> 00:02:50,493 to separate at the thousands.