Questions tagged [signedness]
37 questions
0
votes
5 answers
How do I represent negative char values in hexadecimal?
The following code
char buffer[BSIZE];
...
if(buffer[0]==0xef)
...
Gives the compiler warning "comparison is always false due to limited range of data type".
The warning goes away when I change the check to
if(buffer[0]==0xffffffef)
This feels…

Atilla Filiz
- 2,383
- 8
- 29
- 47
0
votes
1 answer
gdb python pretty printer uint64_t is interpreted signed
When I try to use:
class MyPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
return str(self.val['fData'][0]) + ":" + "%016x" %…

Frank Bergemann
- 325
- 2
- 14
0
votes
2 answers
string concatenation with strncat leads to error in signedness
update: the point of whether char, signed char, or unsigned was ultimately moot here. it was more appropriate to use memcpy in this situation, since it works indiscriminately on bytes.
Couldn't be a simpler operation, but I seem to be missing a…

bitcruncher
- 800
- 1
- 7
- 14
0
votes
1 answer
gcc implicit signedness of constants
I've encountered some interesting behavior with gcc's interpretation of the signedness of constants. I have a piece of code which (greatly simplified) looks like the below:
#define SPECIFIC_VALUE 0xFFFFFFFF
//...
int32_t value = SOMETHING;
if…

Austin Glaser
- 352
- 1
- 12
0
votes
4 answers
C cast and char signedness
So lately, I read on an issue regarding the three distinct types in C, char/unsigned char/signed char. The problem that I now encounter is not something I have experienced up till now (my program works correctly on all tested computers and only…

user209347
- 217
- 3
- 11
0
votes
1 answer
How to send a Java integer in four bytes to another application?
public void routeMessage(byte[] data, int mode) {
logger.debug(mode);
logger.debug(Integer.toBinaryString(mode));
byte[] message = new byte[8];
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
ByteArrayOutputStream baoStream = new…

user1468729
- 71
- 1
- 1
- 3
-1
votes
1 answer
c++ find implicit type conversion in the expression
For the below expression:-
int main()
{
unsigned ui = 1;
float fval = 2.5;
cout << sizeof(ui) << endl << sizeof(fval) << endl;
cout << typeid(ui+fval).name();
}
we get the following output:-
4
4
f
It seems that ui+fval is a…

schwillr
- 87
- 6