From the course: COBOL Essential Training

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Watch for numeric overflow in variables

Watch for numeric overflow in variables - COBOL Tutorial

From the course: COBOL Essential Training

Start my 1-month free trial

Watch for numeric overflow in variables

- One of the things that you need to be really careful about when you're either updating a COBOL program or writing one from scratch, is your numeric overflow. If you're used to programming in Java or C++, this is especially true. So in this table here, I'm trying to demonstrate that an integer variable in COBOL, the size of that value is based on the pic clause. So if you only need the numbers zero through nine, you can use PIC nine, if you need 10 to 99, you can use PIC 99 and then 100 to 999 can be PIC 999. Now as the numbers get increasingly larger, you can start to use your comp three variable types, and that will give you much larger numbers. But if you just need an integer, you can actually define the pic clause accordingly. In Java, if you define an int variable, you automatically have the size of from minus two to 31st, all the way up to two to the 31st minus one. So you really don't worry too much about numeric…

Contents