Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Created September 21, 2010 04:01
Show Gist options
  • Select an option

  • Save inklesspen/589164 to your computer and use it in GitHub Desktop.

Select an option

Save inklesspen/589164 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main(void)
{
uint32_t a = UINT32_MAX - 10;
printf("%" PRIi32 "\n", a);
printf("%" PRIu32 "\n", a);
int32_t b = (int32_t) a;
printf("%" PRIi32 "\n", b);
printf("%" PRIu32 "\n", b);
int32_t c = b + 100;
printf("%" PRIi32 "\n", c);
printf("%" PRIu32 "\n", c);
uint32_t d = a + 100;
printf("%" PRIi32 "\n", d);
printf("%" PRIu32 "\n", d);
return 0;
}
/*
Output:
-11
4294967285
-11
4294967285
89
89
89
89
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment