JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions A bit of fun: fun with bits applying xor to decimal number
 applying xor to decimal number | Reply Hiin SRM 491 250 : OneDigitDifferenceI tried to use xor to state that 2 numbers differ by one digit like :1907654321 , 907654321 but didnt workI want somehow to to use xor to get one digit only when the above caseThanks
 Re: applying xor to decimal number (response to post by mshawki86) | Reply You can only use the normal xor function with binary numbers, but you can do something like the following```int dif(int a, int b) // returns the number of different places {   int num = 0;   while(a>0 || b>0) { if(((a%10)^(b%10))!=0) { num++; } a/=10; b/=10; }   return num; } ```
 Forums Tutorial Discussions A bit of fun: fun with bits applying xor to decimal number Previous Thread  |  Next Thread