H
Hans
Hello,
Thanks for all your response on my question about signed/unsigned chars.
The problem is this: I want to use the char array for a ArrayLookup, so
I need to convert char to unsigned int.
But this doesn't work!
If I try this:
#include <stdio.h>
int main() {
char c = -1; // 129 unsigned and -1 signed right?
// convert it to a value between 0 - 255 for array Lookup
unsigned int arrayIndex = (unsigned int) c;
if (arrayIndex < 0)
printf("ArrayIndex still negative after conversion to unsigned int
%d\n",arrayIndex);
else
printf("Unsigned representation is OK for ArrayIndex=%d\n",arrayIndex);
}
The output is: "ArrayIndex still negative after conversion to unsigned
int -1"
How is this possible?
I would expect a output 129.
Thanks!
Hans
Thanks for all your response on my question about signed/unsigned chars.
The problem is this: I want to use the char array for a ArrayLookup, so
I need to convert char to unsigned int.
But this doesn't work!
If I try this:
#include <stdio.h>
int main() {
char c = -1; // 129 unsigned and -1 signed right?
// convert it to a value between 0 - 255 for array Lookup
unsigned int arrayIndex = (unsigned int) c;
if (arrayIndex < 0)
printf("ArrayIndex still negative after conversion to unsigned int
%d\n",arrayIndex);
else
printf("Unsigned representation is OK for ArrayIndex=%d\n",arrayIndex);
}
The output is: "ArrayIndex still negative after conversion to unsigned
int -1"
How is this possible?
I would expect a output 129.
Thanks!
Hans