I am working with some old data imports and came across a bunch of data from an external source that reports financial numbers with a signed overpunch. I\'ve seen alot, but
Zoned decimal is easy and requires no char manipulation.
private int ConvertOverpunch(byte[] number)
{
// Works for EBCDIC or ASCII, all charsets
int rtnVal = 0;
for(int i = 0; i<number.length; i++)
{
int digit = 0x0f & number[i];
rtnVal = (rtnVal * 10) + digit;
}
// Extract sign
// This works in EBCDIC
// Need to find out what your sign is in ASCII
if(0xD0 & number[number.length-1])
{
rtnVal *= -1;
}
return rtnVal;
}