Advertisement
loulett

HW1_type

Oct 28th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. void print_bytes(const void *mem, int size)
  4. {
  5.     char const *abyrvalg = (const char *)mem;
  6.     const char *abr = abyrvalg;
  7.     for (; abr - abyrvalg < size; ++abr)
  8.     {
  9.         printf("%i%i%i%i%i%i%i%i ", (*(abr)& (1 << 7)) >> 7, (*(abr)& (1 << 6)) >> 6, (*(abr)& (1 << 5)) >> 5, (*(abr)& (1 << 4)) >> 4, (*(abr)& (1 << 3)) >> 3, (*(abr)& (1 << 2)) >> 2, (*(abr)& (1 << 1)) >> 1, (*(abr)& 1));
  10.     }
  11. }
  12.  
  13. int main()
  14. {
  15.     float a = 0;
  16.     scanf("%f", &a);
  17.     print_bytes(&a, sizeof(a));
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement