1 00:00:00,610 --> 00:00:02,010 - [Instructor] In this exercise, we'd like you 2 00:00:02,010 --> 00:00:04,930 to print the two floating point numbers you see here, 3 00:00:04,930 --> 00:00:06,200 and we would like each of those 4 00:00:06,200 --> 00:00:08,470 to be displayed preceded by it's sign, 5 00:00:08,470 --> 00:00:11,830 so we want to force a plus sign on the first value here 6 00:00:11,830 --> 00:00:15,340 in a 10-character field with thousands separators, 7 00:00:15,340 --> 00:00:18,350 and we want their decimal points to be aligned vertically 8 00:00:18,350 --> 00:00:21,200 with two digits to the right of each of those. 9 00:00:21,200 --> 00:00:24,360 So go ahead and pause the video to give that a shot, 10 00:00:24,360 --> 00:00:26,010 then come back to see the answer. 11 00:00:30,560 --> 00:00:33,160 Okay, let's go ahead and reveal that, 12 00:00:33,160 --> 00:00:34,930 and as you can see here, 13 00:00:34,930 --> 00:00:38,460 we are doing a couple of placeholders 14 00:00:38,460 --> 00:00:40,820 in our format string that will be printed. 15 00:00:40,820 --> 00:00:43,710 For the first value, we wanted to force it 16 00:00:43,710 --> 00:00:47,250 to display it's sign no matter what. 17 00:00:47,250 --> 00:00:50,890 We're going to do this in a field of 10. 18 00:00:50,890 --> 00:00:53,380 We've got the comma to indicate 19 00:00:53,380 --> 00:00:55,970 that we want to do the thousands separator 20 00:00:55,970 --> 00:00:58,900 and we want two digits to the right of the decimal point 21 00:00:58,900 --> 00:01:00,530 for this floating point number 22 00:01:00,530 --> 00:01:04,290 and then we used the same specifier for the other value 23 00:01:04,290 --> 00:01:06,070 even though it's a negative value, 24 00:01:06,070 --> 00:01:09,010 we still put in the plus sign here, but of course, 25 00:01:09,010 --> 00:01:12,010 a plus sign will not appear because it's negative. 26 00:01:12,010 --> 00:01:13,930 So let's go ahead and execute that 27 00:01:13,930 --> 00:01:15,960 and you can see a couple of things here. 28 00:01:15,960 --> 00:01:17,300 First of all, the two digits 29 00:01:17,300 --> 00:01:19,250 to the right of the decimal point, 30 00:01:19,250 --> 00:01:22,450 remember the numbers are right aligned automatically 31 00:01:22,450 --> 00:01:26,870 in format specifiers unless you indicate otherwise, 32 00:01:26,870 --> 00:01:30,130 so the fields of 10 were a little bit wider 33 00:01:30,130 --> 00:01:32,040 than each of the two values in this case 34 00:01:32,040 --> 00:01:34,690 and also notice the comma separators 35 00:01:34,690 --> 00:01:37,763 and the plus sign before the positive value.