signedness

Can someone explain how the signedness of char is platform specific?

I recently read that the differences between char unsigned char and signed char is platform specific. I can't quite get my head round this? does it mean the the bit sequence can vary from one platform to the next ie platform1 the sign is the first bit, platform2 the sign could be at the end? how would you code against this? Basica...

Worst side effects from chars signedness. (Explanation of signedness effects on chars and casts)

I frequently work with libraries that use char when working with bytes in C++. The alternative is to define a "Byte" as unsigned char but that not the standard they decided to use. I frequently pass bytes from C# into the C++ dlls and cast them to char to work with the library. When casting ints to chars or chars to other simple types w...

Array's index and argc signedness

Hello, The C standard (5.1.2.2.1 Program startup) says: The function called at program startup is named main. [...] It shall be defined with a return type of int and with no parameters: int main(void) { /* ... */ } or with two parameters [...] : int main(int argc, char *argv[]) { /* ... */ } And later says: Th...

Difference between C# and java big endian bytes using miscutil

I'm using the miscutil library to communicate between and Java and C# application using a socket. I am trying to figure out the difference between the following code (this is Groovy, but the Java result is the same): import java.io.* def baos = new ByteArrayOutputStream(); def stream = new DataOutputStream(baos); stream.writeInt(5000)...

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 critical step. In the following code, I am attempting to fill bufferdata with buffer for wh...

For any finite floating point value, is it guaranteed that x - x == 0?

Floating point values are inexact, which is why we should rarely use strict numerical equality in comparisons. For example, in Java this prints false (as seen on ideone.com): System.out.println(.1 + .2 == .3); // false Usually the correct way to compare results of floating point calculations is to see if the absolute difference agains...

Are bytes/words/addresses signed or unsigned in Z80 assembler/machine code?

I am making an emulator for Z80 binaries but I cannot find out whether all the integer data types are signed or unsigned from the manual or from google. So are the numbers from registers A,B...HL,BC etc signed or not? Also, in machine code are the bytes/words/addresses which come after the instructions as arguments signed or unsigned? ...

Is the signedness of char an interface issue?

Suppose I have a function void foo(char *) which, internally, needs to treat its input as a block of NUL-terminated bytes (say, it's a hash function on strings). I could cast the argument to unsigned char* in the function. I could also change the declaration to void foo(unsigned char *) Now, given that char, signed char and unsigne...