Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskoz/41688b9480f96239719b to your computer and use it in GitHub Desktop.
Save vaskoz/41688b9480f96239719b to your computer and use it in GitHub Desktop.
#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*/
#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*/
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