In C, why is “signed int” faster than “unsigned int”?

后端 未结 4 1926
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 12:05

In C, why is signed int faster than unsigned int? True, I know that this has been asked and answered multiple times on this website (links below).

4条回答
  •  猫巷女王i
    2020-12-25 12:38

    Alternative wiki candidate test that may/may not show a significant time difference.

    #include 
    #include 
    
    #define J 10
    #define I 5
    
    int main(void) {
      clock_t c1,c2,c3;
      for (int j=0; j

    Sample output

    2761 2746 -15
    2777 2777 0
    2761 2745 -16
    2793 2808 15
    2792 2730 -62
    2746 2730 -16
    2746 2730 -16
    2776 2793 17
    2823 2808 -15
    2793 2823 30
    

提交回复
热议问题