Very old Mainframe COBOLs did allow -ve zero to exist. 

The test for a zero where the source may have been a negative zero should have 
been unproblematic, because at the time only "decimal" instructions were used 
for numeric comparisons in the code generated by the compiler. And zero is zero.

When IBM decided to use "character" comparisons where possible for numerics, 
they had to ban the negative zero. Although in a decimal compare a zero is 
zero, no matter how signed, in a character compare it is not. Ergo -ve zero 
could not be allowed to exist. (you can of course screw things up by being 
deliberate, but no calculation in COBOL will ever generate a -ve zero result, 
nor will any truncation).

There's lots of ways the problem being talked about probably happened: PIC 99 
and test for greater than 100 is a good one. PIC 9(4) and with subtraction, 
test for less than zero. One of my favourites "ADD ONE TO somefield" where 
data-name ONE is defined with VALUE ZERO. 

How about this fun one. Job running a long time, so someone decides to cancel 
it. Investigation reveals that it was processing the final record on the file. 
Some bright spark says "it's a pity we cancelled it, it had nearly finished, 
let's submit it again..." and they were going to. The loop was in processing 
some accumulated totals, and was of the type mentioned above. I think the job 
was originally cancelled after about three hours. With the code corrected, it 
ran in under 10 minutes. I had only arrived at the final conversation. One of 
those moments when you feel you've stepped into some sort of alternate 
Universe...

And don't ask how it got through testing...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to