Created
January 22, 2013 15:55
-
-
Save rodchile/4595758 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
// | |
// 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