I was recently studying about two's complement and how we can use the same hardware to do add, subtract and multiply two numbers regardless of whether they are signed or unsigned. Then i remembered that in static compiled languages such as C we need to explicitly tell to the compiler if the number is signed or unsigned.
I Do understand that while the CPU ALU (i think) does not need (or does not want) to know if the number is signed or unsigned, but the compiler needs! so we can do the correct computations, comparisons, and handle input/output better.
My low-level inclined question is:
At the lowest level, does the computer REALLY doesn't need to know if the numbers are signed or not, is it really a COMPILER-ONLY concern ?
I Did some experiments here some of the interesting results:
(C Code) Changing if the b is signed or unsigned in code
Generated Assembly from the C code (comparison parts only)
Not much of a difference in the assembly code, but it does differ, which i found interesting. So it seems that signed or unsigned is just a compiler and programmer concern, so we can generate the correct code, i am missing something ?, some low-level detail ?, does the cpu totally ignores if the number is signed or not ?
The cpu totally ignores if the number is signed or unsigned ?