Binary To Decimal Conversions

This example shows the conversion of Decimal to Binary & Binary to Decimal  in Java.

The toBinary() method in BinaryConversion class uses the recursion logic of modulo(%) 2 of given number(which is reminder), and calls the same method recursively with number/2( from 512>>2 =256) , until the reminder is one.

The toDecimal() method uses the recursion logic by calling the same method and add the result of last digit multiplied by 2.,

Binary Conversions:


Leave a Reply

Your email address will not be published. Required fields are marked *