Posts

Showing posts with the label number system

Number System Binary to Octal Conversion

Image
It is a C program which executes number system conversion from binary to octal numbers. Binary to Octal - algorithm set octal [] Read binary_bits form user reverse(binary_bits) while not EOF(binary_bits) read 3-bits from binary_bits convert 3-bits to decimal append decimal to octal end print reverse(octal) Binary to Octal conversion example The given binary number is 01101010010 and converts it into octal number binary = 01101010010, octal = ?, split binary 3 bits group from right to left direction and carried out binary to decimal conversion on each 3 bits group binary = 01 | 101 | 010 | 010 octal = 1 5 2 2 if...

Convert Octal to Binary

Image
The C program carry out number system conversion from a octal value (base-8) to binary numbers (base-2) is called octal to binary conversion. A octal number is represented by binary 3 bits. Octal number system The octal number system has the following unique digits. {0, 1, 2, 3, 4, 5, 6, 7} As the octal number system has the 8 unique digits, it is called base 8 or radix 8 number system. Each octal digit can be represented by binary 3 bits. Binary number system The Binary number system has the following unique digits. {0, 1} As the binary number system has the 2 unique digits, it is called base 2 or radix 2 number system. The computer can only understand this number system and is operated by this binary number system, therefore it accepts data,instruction and everything in binary numbers format. Octal to Binary conversion example ...

Binary to Hexadecimal Conversion

Image
The number system conversion C program which converts binary number to a hexadecimal number, is called binary to hexadecimal conversion. alternatively, it is said be a conversion from base-2 to base-16 number system or radix-2 to radix-16 number system conversion. Binary to Hexadecimal - algorithm set hexa =[] Read binary_bits form user reverse(binary_bits) while not EOF(binary_bits) read 4-bits from binary_bits convert 4-bits to decimal append decimal to hexa end print reverse(hexa) Binary to Hexadecimal conversion example The given binary number is 11101101010110 and converts it into hexadecimal number binary = 11 1011 0101 0110, hexadecimal = ?, 1. split binary numbers into 4 ...

Decimal to Binary Conversion - Bitwise Right shift Operator

It is a number system conversion from decimal value into binary bits is carried out using bitwise >> (right-shift) operator. The Right shift operator moves the bit position of a integer towards right direction. it removes bits from LSB (least significant bit) and add bits (0s) into MSB (most significant bit) and the number bits to remove and to add depends on a operand value next to the right shift operator. For example, the integer variable x=10 , move 1 bit using right-shift binary 8-bits x = 00001010 x = x >> 1 move 1 bit (remove one bit from LSB (0) and add one bit (0) into MSB binary 8-bits x = 00000101 and x's decimal value becomes 5. Decimal to binary conversion using Bitwise Right-shif...

Binary to Decimal Conversion - Bitwise Right shift Operator

It is number system conversion from binary (base -2) to decimal (base -10) is carried out by bitwise >> (right-shift) operator. The Right shift operator moves the bit position of a integer towards right direction. it removes bits from LSB (least significant bit) and add bits (0s) into MSB (least significant bit) and the number bits to remove and to add depends on a operand value next to the right shift operator. For example, the integer variable x=74 , move 2 bit using right-shift operator binary 8-bits of x = 01001010 x = x >> 2 move 2 bit (remove two bits from LSB (10) and add two bits (00) into MSB 2-bits shifted binary 8-bits of x = 00010010 and x's decimal value becomes 18. Binary to decimal conversion using Bitwise Right-shift...

Decimal to Binary Conversion - Bitwise Left shift operator

It is a number system conversion from decimal to binary, which is implemented by bitwise left shift operator. The left-shift operator shifts the bits of the decimal value towards left direction. it removes MSB bits and adds bits 0s on LSB of the decimal value. Decimal to Binary Conversion by Left-shift -Manual calculation Given decimal value =19, converts into binary bits. on each iteration, AND (bitwise operation ) with the decimal value and 128, if condition is true, returns 1, otherwise 0, the decimal left shift by 1 , resultant value stored on the same decimal value.  n (decval AND 128) Operation    Decval = decval << by 1 0 bit[0] = (19 AND 128) ? 1:0   38 = 19 <<1 1 bit[1] = (38 AND 128) ? 1:0   76 = 38 <<1 2 bit[2] = (78 AND 128) ? 1:0   152 = 38 <<1 3 bit[3] =...

Binary to Decimal conversion

Image
The binary number consists of 0's and 1's such a number system has only two distinct digits : {0,1} is called base-2 number system and The decimal number consist of 0's to 9's such a number system has 10 distinct digits {0,1,2,3,4,5,6,7,8,9} is called base 10 number system. The binary to decimal conversion is carried out by following manner. Binary to Decimal - Example of Manual Conversion example given binary bits=10101 convert it into decimal value =? decimal value =1x2^4 + 0x2^3 + 1x2^2 + 0x2^1 + 1x2^0 =1x16 + 0x8 + 1x4 + 0x2 + 1x1 =16 + 0 + 4 + 0 + 1 decimal value = 21 Binary to Decimal conversion - algorithm Declaration Input Read char bits Output integer decval Temp var char abit; integer len,n=0     len = strlen(bits) Loop n =0 to len-1 abit= bits[len-n-1] ...

Decimal to 8 bit Binary conversion

Image
The binary number has two digits {0,1} is called base-2 number system, while the decimal number system has 10 digits {0,1,2,3,4,5,6,7,8,9} is called base-10 number system. The conversion between decimal (base-10) to 8-bit binary (base-2) is carried out by arithmetic modulus and division operators. The decimal to binary conversion returns 8-bit binary number result for any decimal value given between 0 to 255. for example, if given a decimal value is 19, return 8-bit binary result will be 00010011. for example, if given a decimal value is 83, return 8-bit binary result will be 01010011. Decimal to 8 bits binary conversion - algorithm Variable Declaration Input Read integer decval Output char bits[9] Temp var integer n,reminder     Loop decval not equal zero reminder = decval module by 2 bits[n] = reminder decval = decval divide by 2 n=n+1 End L...

Decimal to Binary Conversion

Image
The binary number consists of 0's and 1's such number system has only two distinct digits {0,1} is called base-2 number system or radix-2 number system. and The decimal number system consist of 0's to 9's has 10 distinct digits {0,1,2,3,4,5,6,7,8,9} is called base-10 number system or radix-10 number system. The decimal to binary conversion or base-2 number to base-10 number conversion is carried out by c programming code. The decimal number is to convert is read from user during the program execution. Decimal to Binary Conversion - Example Example decimal value =23 converts it into equivalent binary bits =? The decimal-value divide by 2 returns a quotient and a reminder, in which the quotient turns decimal-value to next round. This process repeated until quotient becomes 0 or 1. round Decimal divider quotient reminder 1 23 ...