# Thread: checking if binary numbers are palindromic

1. ## checking if binary numbers are palindromic

hey all, jus need a lil help. ok. got an assignment to make a C program to find all the palindromic primes from 1 to 10000, convert them to binary and chek if the binary representation is palindromic for each, then output only the palindromic primes to a txt file with time stamps.
well i think i kinda have it but cant really code the last part which is taking the binary numbers and cheking if they are palindromic. teacher said we can get it using bitwise operators but i have no idea how to use them to do that. i kno i either hav to compare the first and last digit, then the second and the second to last digit, and so on to see if its a palindrome. or take the number and print it backwards and check if they are ==. so yea i dont kno how to take my binary number which i am already printing and code it to chek if its a palindrome . any help? thanks

2. if you already have a way to check if a prime (or any number) is 'palindromic', doing it with a binary number shouldnt be much different. how did you do it with the other (base-10) numbers? if you converted the number to a string first, then your function should work with the binary numbers to with no change. just convert the binary number to a string before you call the function.

if you dont have a function to convert a number to a string, look at this link. notice the comment and sample code in the 'portability' section.

hope it helps

3. thanks alot will look into that link and see if i can use it. thing is i dont have a function that tests if an integer is a palindrome. thanks again.

4. Yup it worked, thanks alot nadroj. big help. i used the function and then made a palindrome function.peace.