I have to move value of 10220 to s9(04) binary field.
I read in the cobol book that s9(04) binary can accomodate nbrs range from -32000 to +32000.
But when tried to move 10220 in this field..Data is getting truncated and saving only 4 digits like 0220.
Is there any way to accomodate this requirement instead of increasing the size of the receIving field.
Joined: 23 Mar 2007 Posts: 149 Location: Ottawa Canada
The compile TRUNC option is key to your question.
Our shop has a standard that says we have to use TRUNC(OPT). This standard was based on some performance benchmarks that showed that TRUNC(OPT) runs significantly faster than the others. I am a bit skeptical about this but no big deal I guess...
Using TRUNC(OPT), this is what we observe...
The MOVE statement can safely move the value 12345 into a PIC S9(4) COMP field. However, the COMPUTE statement will truncate any result back to 4 digits. Very weird.