Posts

Showing posts with the label binary to decimal

mathajax

Binary to Real number conversion

The number system conversion is carried out for a binary numbers (base-2) into real number (base 10). The input binary bit sequence consists of integer and fraction binary bits separated by a decimal point. The integer bits and fractional bits are converted into decimal value separately and then combined to print real value as a result of given binary bit sequence. The fractional part of binary bits are converted into decimal fraction value by multiplication of the bits by 2 power of negative positional value of the bits. Binary to Real number Conversion - Manual Calculation Given input binary numbers = 1110.1001, converts it into a real number. separate binary bits into integer binary bits and fractional binary bits by a delimiter . (point) binary bits (integer part) = 1110 binary bits (fraction part) = 1001 Binary bits (integer part) into decimal conversion binary bits (integer part) ...

Decimal to Binary & Binary to Decimal - Bitwise Left-shift Operator

Image
The Java code has two number conversion operations; first is decimal to binary conversion and second binary to decimal conversion . The bitwise left shift operator used in these both operation.  Conditional switch selects the case, one of the two conversion operation is to carry out from choice input given to program. If choice is 1, switch selects case1 ( binary to decimal conversion ) and if choice is 2, switch selects case2 (decimal to binary conversion). Binary to Decimal Conversion  Assume that, choice is 1 and switch selects binary to decimal conversion operation. The user is prompted enter 8 binary bits as input which is to be converted into a decimal value.Assume that, binary input given is 01100000 and it is stored into a string object “bstr” and initialize decval  = 0. bstr  =”[01100000]”  index start 0 from left to right. decval =0; iteration  n=0 decval   = decval <<1;     decval leftshift by 1 bit (re...

Binary to Decimal & Decimal to Binary Bitwise Right-shift Operator

Image
The Java code has two number conversion operations; one is decimal to binary conversion and second binary to decimal conversion . These two operations are done by bitwise right shift operator .  Conditional switch selects the case, one of the two conversion operation is to carry out from choice input given to program.  If choice is 1, switch selects case1 ( binary to decimal conversion ) and if choice is 2, switch selects case2 ( decimal to binary conversion ). Decimal 2 Binary by Right shift  Binary to decimal conversion  Assume that, choice is 1 and switch selects binary to decimal conversion operation. The user is prompted enter 8 binary bits as input which is to be converted into a decimal value . Assume that, binary input given is 011000000 and it is stored into a string object “bstr” and initialize decval  = 0.   Bstr  =”[01100000]”   characters indexed (0,1,2,.)  from left to right  decval =0; the it...

Decimal to binary and Binary to decimal

The number system conversion process is carried out between base 10 and base 2 number system . The base 10 number system has 10 distinct numbers from 0 to 9 is called decimal number system and the base 2 number system has 2 distinct numbers 0 and 1 is binary number system . Decimal to binary (base 10 to base 2) conversion - algorithm Given a decimal value, decval and converts it into binary bits modulus decval by 2, it returns a reminder ( 0 or 1) divide decval by 2, it returns a quotient the quotient becomes the decval and repeat step 1 to 3 until decval becomes 0 the reminders on each iteration is results of binary bits Decimal to binary (base 10 to base 2) conversion - Example Given decimal value = 47 ,convert it into binary bits divide the decimal value by 2 returns a quotient and ...

Binary to Decimal Conversion

It is a number system conversion from binary to decimal number system that is carried out by arithmetic operation addition and a power function. Binary to Decimal conversion - steps Given binary 8 bits, converts it into decimal value set decval==0 Read a LSB bit from binary8bits IF LSB==1    add decval + 2 power of the LSB position value End IF Next LSB print decval binary to decimal value conversion - Example Given binary 8 bits = 10001111 ,convert it into a decimal value. The position value(0 to n-1 bits) starts right to left on the binary bits. 1000 1 1 1 1 | | | | |-----1 x 2^0 = 1 | | | |---------1 x 2^1 =2 | | |-------------1 x 2^2 =4 | | ----------------1 x 2^3 =8 | ...