Incidentally, IIRC, bit value of -40 is 11011000 because
two's-complement is used to represent negative numbers.
40 = 0010 1000
1101 0111 <- one's-complement
1 <- add 1 for two's-complement
-40 = 1101 1000 <- two's-complement of 40 is -40
D 8 <- D8 is EBCDIC 'Q'
I think... ;-)
Behalf Of Elvis Budimlic
Sent: Friday, November 09, 2007 4:25 PM
To: 'C programming iSeries / AS400'
Subject: Re: [C400-L] subtract two char value?
Char values are int data type, but not really. Only last byte is used
and other leading 3 bytes are ignored.
There is no problem subtracting two ints, as long as it makes sense in
If you look at the EBCDIC table of values 'H' = 200 and '0' = 240. When
you subtract these two values you get -40. However, bit value of single
byte -40 is 11011000. If you then ignore the sign (as system must do,
since it's unsigned char) and look at it as unsigned byte value, you
interpret that bit mapping as 216. Guess what EBCDIC character is for
216? Yes, it is 'Q'.
Now, why would anyone want to do that... it escapes me.
I'm sure you know the answer from the context of your program.
Celebrating 10-Years of SQL Performance Excellence on IBM i5/OS and
Subject: [C400-L] subtract two char value?
I ran into code below and confuse about the line where it subtract two
unsigned int Hex2Int(char cC)
default:return(cC-'0');break; <== What is this mean? How can C
subtract two char values?
I wrote a test program below and the result of 'H'-'0' is 'Q'. Huh?
cC = 'H';
result = cC-'0';
This is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at