Output integers per bit & two integer binary representation of different bit digits &c language operator Summary __c language

Source: Internet
Author: User
Tags pow
output every bit of an integer
#include <stdio.h>
#include <math.h>

int main ()
{
  int i = 0;
  int y = 0;
  int j = 0;
  int z = 0;
  int x = 0;
  scanf ("%d", &i);
  j = i;
  Computes the bit number of the integer while
  (j)
  {
      j = J/10;
      y++;
  }
  printf ("This number has%d bits \ n", y);
  Outputs the number for each digit for
  (x=0; x<y; y--)
  {
      z = i/(int) (POW (y-1));
      i = i% (int) (POW (y-1));
      printf ("%d", z);
  }
  return 0;
}
two int integer binary tab, how many bit bits are different.
 #include <stdio.h> int main () {int x = 0;
  int y = 0;
  int i = 0;
  int j = 0;
  int count = 0;
  scanf ("%d,%d", &x,&y);  i = (sizeof (x>y) (x:y)) *8;
  Bit printf used to compute the larger value ("The larger number in the two digits has%d bit bits \ n", i);
      For (j=0 j<i; j + +)//////////////////////////////////////////////////////////////  count++;
    The cumulative one at a time}//two digits to the right one x = x>>1;
  y = y>>1;
  printf ("%d digits different \ n", count);
return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.