Last active
August 29, 2015 14:13
-
-
Save vaskoz/41688b9480f96239719b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (void) | |
{ | |
int a = -1; | |
unsigned int b = 2; | |
printf("%d\n", 1 > 0); // TRUE == 1 | |
printf("%d\n", 0 > 1); // FALSE == 0 | |
printf("%d\n", a > b); // -1 > 2 apparently TRUE == 1 | |
printf("%d\n", -1 > 2u); // -1 > 2unsigned apparently TRUE == 1 | |
printf("%d\n", -1 > 2); // -1 > 2 FALSE == 0 | |
} | |
/*gcc compare.c ; ./a.out*/ | |
/*1*/ | |
/*0*/ | |
/*1*/ | |
/*1*/ | |
/*0*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main (void) | |
{ | |
int a = -1; | |
unsigned int b = 2; | |
std::cout << (1 > 0) << std::endl; // TRUE == 1 | |
std::cout << (0 > 1) << std::endl; // FALSE == 0 | |
std::cout << (a > b) << std::endl; // -1 > 2 apparently TRUE == 1 | |
std::cout << (-1 > 2u) << std::endl; // -1 > 2unsigned apparently TRUE == 1 | |
std::cout << (-1 > 2) << std::endl; // -1 > 2 FALSE == 0 | |
} | |
/*g++ compare.cpp ; ./a.out*/ | |
/*1*/ | |
/*0*/ | |
/*1*/ | |
/*1*/ | |
/*0*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
var i uint = 5 | |
for i >= 0 { // NO COMPILE WARNING | |
println(i) | |
i-- | |
} | |
} | |
/*go run compare.go | |
INFINITE RUN | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment