fork download
  1. #include <stdio.h>
  2.  
  3. void useSignedNumbers();
  4. void useUnsignedNumbers();
  5.  
  6. int main()
  7. {
  8. printf("--------- signed -----------");
  9. useSignedNumbers();
  10. printf("\n");
  11. printf("-------- unsigned: ---------");
  12. useUnsignedNumbers();
  13. return 0;
  14. }
  15.  
  16. void useSignedNumbers() {
  17. int byte_1 = 165;
  18. int byte_2 = 200;
  19.  
  20. printf("\n%i", byte_1);
  21. printf("\n%i", byte_2);
  22.  
  23. byte_1 = ~byte_1;
  24. byte_2 = byte_2 >> 3;
  25.  
  26. printf("\n%i", byte_1);
  27. printf("\n%i", byte_2);
  28.  
  29. if ((byte_1 > 200) & (byte_2 < 180)) {
  30. printf("\ntrue");
  31. }
  32. else {
  33. printf("\nfalse");
  34. }
  35.  
  36. if ((byte_1 < 200) | (byte_2 > 180)) {
  37. printf("\ntrue");
  38. }
  39. else {
  40. printf("\nfalse");
  41. }
  42.  
  43. if ((byte_1 < 200) ^ (byte_2 > 180)) {
  44. printf("\ntrue");
  45. }
  46. else {
  47. printf("\nfalse");
  48. }
  49. }
  50.  
  51. void useUnsignedNumbers() {
  52. unsigned int byte_1 = 165;
  53. unsigned int byte_2 = 200;
  54.  
  55. printf("%u", byte_1);
  56. printf("\n%u", byte_2);
  57.  
  58. byte_1 = ~byte_1;
  59. byte_2 = byte_2 >> 3;
  60.  
  61. printf("\n%u", byte_1);
  62. printf("\n%u", byte_2);
  63.  
  64. if ((byte_1 > 200) & (byte_2 < 180)) {
  65. printf("\ntrue");
  66. }
  67. else {
  68. printf("\nfalse");
  69. }
  70.  
  71. if ((byte_1 < 200) | (byte_2 > 180)) {
  72. printf("\ntrue");
  73. }
  74. else {
  75. printf("\nfalse");
  76. }
  77.  
  78. if ((byte_1 < 200) ^ (byte_2 > 180)) {
  79. printf("\ntrue");
  80. }
  81. else {
  82. printf("\nfalse");
  83. }
  84. }
Success #stdin #stdout 0s 4284KB
stdin
Standard input is empty
stdout
--------- signed -----------
165
200
-166
25
false
true
true
-------- unsigned: ---------165
200
4294967130
25
true
false
false