Hello. This is kevin. I have a friend who is a school teacher. A real good one, and an excellent writer. But mathematics not his favorite thing. Well, today we get to study arithmetic whether it's your favorite class or not. In this lesson we will learn to use COBOL statements to ADD, SUBTRACT, MULTIPLY, DIVIDE and COMPUTE. Understand the order of evaluation, ROUND arithmetic results when necessary, validate accuracy of results using ON SIZE ERROR. As you likely know, COBOL arithmetic has five verbs, ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE. Which can be used also for exponents. COBOL can store a maximum of 18 digits for each number. And there are two options available, something called ROUNDED and something called ON SIZE ERROR, that we'll get to. There are two formats for adding numbers. Always start with the word, ADD, then code, a numeric literal or the name of one or more fields that are being added. Last, there are two formats for storing the calculation, coding to that is the letters T, O, followed by the storing field or GIVING if you are calculating multiple numbers. Several examples are on your screen from simply adding what is in A-NUMBER TO B-NUMBER. Adding two numbers to C-NUMBER. Adding the number of 57 TO EMPLOYEE-BONUS. A bonus? That sounds good. The last two numbers demonstrate two options, ROUNDED and something called ON SIZE ERROR. Let's pause to explain these, ROUNDED makes a number simpler while keeping its value close to what it was. We're looking at two numbers that have six digits, 912 .114 and 912.115. These numbers will be stored in a field that has only five digits. The excess digit is dropped if that digit was five or larger. Rounding up occurs by adding one to the last digit. The second arithmetic option is ON SIZE ERROR. Every numeric field has a limit. If a calculation exceeds the limit, we need to have some kind of an alarm that will go off because there's no more room to store the value. In addition, if you do division by zero, that will always cause an error as well. Here are three examples. The format for subtracting is very similar to adding, ROUNDED and ON SIZE ERROR can also be used if necessary. The examples on this screen are simply subtracting what is in A-COST, and B-COST from C-COST. Subtracting what you spent at lunch, say on food, drink and dessert from my wallet. Then the third example is subtract with the possibility of an ON SIZE ERROR which we might need. And then here we have the format for multiplying. It's very similar to add and subtract. Here are some MULTIPLY examples, first, doubling the employee's wage by 2. That sounds like a great idea. Second, our investment grows by 7%, not bad. Third, is keeping track of some money borrowed from the bank and the two possibilities based ON SIZE ERROR. Dividing is more challenging, but there's two formats you've seen before. We can use a giving option or not, and ROUNDED and ON SIZE ERRORS are still welcome. We have number1 being divided by number1 with the results stored in number2. Only number2 changes, number1 does not change. The second example, amount2 is divided by amount1. With the results stored in amount3. Amount2 and amount1 will not change. The format for compute is different. The arithmetic for ADD, SUBTRACT, MULTIPLY and DIVIDE are on the right, while the solution with compute is on the left. ROUNDED and ON SIZE ERROR are optional. Let's take a closer look at five compute examples. First example, we have 900 stored in counter1. Second, A1 plus B1 plus C1 equals total counter. The third example, 2 to the 5th power is stored in total-1. The fourth example, a complex calculation that we'll discuss in a moment. And number five Is counter is increased by 20%, on size is there if needed. Two more things, the symbols and the sequence. The symbols, we can use with the compute command are listed here on your screen. Also, the order of calculations is listed here as well. The order is that things that have parentheses go first, then exponents. And then there's a tie with division and multiplication, and finally there is addition and subtraction. So during this lesson, we saw how we can use COBOL statements to ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE, to better understand the order of evaluation. To use the ROUND with arithmetic results, and validate accuracy of results using the ON SIZE ERROR. Hope you've enjoyed this mathematical journey.