How to reverse a binary number for example 001 into 100 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to reverse a binary number for example 001 into 100

java

8th Sep 2017, 11:52 AM
Praveen Patil
Praveen Patil - avatar
9 Answers
8th Sep 2017, 1:39 PM
Bodan Talev
Bodan Talev - avatar
+ 11
Save the binary number as string, reverse the string. You can search Code Playground for all kinds of string reversing algorithms.
8th Sep 2017, 11:57 AM
Hatsy Rei
Hatsy Rei - avatar
8th Sep 2017, 1:40 PM
Bodan Talev
Bodan Talev - avatar
8th Sep 2017, 12:10 PM
Bodan Talev
Bodan Talev - avatar
+ 3
oh, no clue.. try searching on google or in the code playground
8th Sep 2017, 1:35 PM
Bodan Talev
Bodan Talev - avatar
+ 3
thanks it works......
8th Sep 2017, 1:45 PM
Praveen Patil
Praveen Patil - avatar
+ 1
my question is if i want a program to print binary number of any number for example if i put x=4 then Output should 100.
8th Sep 2017, 12:24 PM
Praveen Patil
Praveen Patil - avatar
+ 1
buddy not found everywhere i searched
8th Sep 2017, 1:36 PM
Praveen Patil
Praveen Patil - avatar
+ 1
@Praveen Patil wrote: << buddy not found everywhere i searched >> You've probably not enough searched, or in a bad way (not surprising as you even doesn't success to correctly explain your purpose in your main question ;P) Converting a number to binary could be done by integer divide by 2 (the base of binary) as long as your number is different from zero, and store remainders in a string from right to left... This is necessarly foundable anywhere ^^ (more basic math than programming question, even if base 2 is often related to computers)
8th Sep 2017, 2:00 PM
visph
visph - avatar