Skip to content

Instantly share code, notes, and snippets.

@rodchile
Created January 22, 2013 15:55
Show Gist options
  • Save rodchile/4595758 to your computer and use it in GitHub Desktop.
Save rodchile/4595758 to your computer and use it in GitHub Desktop.
//
// main.c
// first_program
//
// Created by Rodrigo Garcia on 1/18/13.
// Copyright (c) 2013 Rodrigo Garcia. All rights reserved.
//
#include <stdio.h>
int main(int argc, const char * argv[])
{
int upper = 2147483647;
for(int i = 31 ; i >= 0 ; i--){
int test = (int) pow(2,i);
int bit =(upper & test);
printf("%c",(bit == 0? '0':'1'));
if(0 == (i % 8) && i > 0){
printf("-");
}
}
unsigned int upperU = (unsigned int) upper;
printf("\n");
printf("upper as 'int' = %d \n",upper);
printf("upper as 'unsigned int' = %d \n",upperU);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment