Question: > 
> **Possible Duplicate:**  
> 
> [performance of unsigned vs signed integers](https://stackoverflow.com/questions/4712315/performance-of-unsigned-vs-signed-integers) 
> 
> 
> 

I have read somewhere that it's a tiny bit faster on `x86_64` to compare `signed ints` in `C/C++` compared to `unsigned ints`, e.g. `for (int i...`) is "faster" than `for (uint i...)`.

Is that true? Why is that true? I know the difference is super small, but anyway.

Answer: 
Maybe in some cases, signed integers force the compiler to sign-extend them.  

If you move an integer to `eax`, then the high bits of `rax` are set to zeros (the low bits are the bits of `eax`). If it's an integer, you need to set the high 32 bits to the sign of the low 32 bits. It's one extra instruction.

I'm not sure this sign extension is needed in a simple `for (i=0; i<MAX; i++)`.
**Measure**

Measurement on the platform has always been the only method of answering those kind of questions (and x86\_64 is just a starting point for determining the platform, the precise model may be needed). Nowadays, the optimizations made on chip (look out what "superscalar out of order processor with speculative execution" means) and by the compilers make those kind of differences (assuming they exist, which I don't really for signed/unsigned comparisons, but optimizations like value range propagation and strength reduction may have an influence) so context dependant that a measurement in the desired context is needed as it will have an influence on the result (I've had code where putting some integer variables as double make it performs better on some machines, worse on others).