Idea is to shift the first four to lower level bits. On the other side, you
have to shift up and then pad by shifting down.
Get first four of byte (shift to lower level bits):
byte byteB = (byteA >> 4) ;
Get second four of packed byte (shift up and then pad):
byte byteC = (byteA << 4) >> 4);
You can also replace the first four bits with an and on 00001111 or byte =
15. An anding version is:
byte byteC = byteA & 0xF;
That should and out the top bits and leave only the four low level bits.
To turn this into a decimal, you have to know how many bytes are before and
after the decimal. You then multiply and divide individual bytes by
multiples of 10.
If the packed field is signed, you have to figure out which bit indicates
signing. On some systems it is the first byte, on others the last. I have
not examined all IBM code pages, so there may be some that use a single bit
for + and -, but I would doubt it.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
|
*************************************************
Cowboy (Gregory A. Beamer) said:
You can get a packed field out quite simply by bit shifting the bytes and
then converting to a decimal value. I do not have a library readily
available. I might be able to find a sample, but I am not certain. Have
not worked with EBCDIC in quite some time.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box! |
*************************************************