## Decimal to BCD (Binary Coded Decimal)

Decimal to BCD (Binary Coded Decimal)
# 1 Decimal to BCD (Binary Coded Decimal)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary Coded Decimal) representation. Also, draw its Flow Chart. 2. Relevant commands, code, scripts, algorithms:

UNIX

3. The attempts at a solution (include all code and scripts):

1:[enter the number]
2:[find the length]
leng=length(n)
a=0
3:[perform the conversion]

for i=0 to leng-1
n1=n1%2[to take the right most digit]

for j=0 to 3
n2=n1%2[to take the reminder]
ans[a]=n2
a++
n1=n1/2
end for

n=n/10[to take the number except the right digit]
end for

[print the number]

fori=a-1 to 0
print ans[i]
end

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

IGNOU / NewDelhi / BCA

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 caramba View Public Profile for caramba Find all posts by caramba
# 2
You can use the bc command to change bases. man bc to read up on obase.
 codecaine View Public Profile for codecaine Find all posts by codecaine
# 3
Quote:
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

IGNOU / NewDelhi / BCA

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
You need to provide complete information or you cannot post homework here:

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
 Neo View Public Profile for Neo Visit Neo's homepage! Find all posts by Neo

## Negative decimal to binary

Is there a fast way to convert a negative decimal value into a signed binary number in bash script ? I've looked a lot on internet but I saw nothing... (For exemple : -1 become 11111111.)

## Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to...

## Binary to decimal for particular bits

Hello, I have script which work fine on particular data.file . The next feature I want to achieve is to get the decimal equivalent of data to data. The data looks like this : data(01000000000000000000110000000000) thank you.. #include <iostream> #include <fstream> #include...

## Convert hexa decimal to decimal

Hi, I want to convert two hexadecimal numbers to decimal using unix command line. 1cce446295197a9d6352f9f223a9b698 fc8f99ac06e88c4faf669cf366f60d I tried using `echo "ibase=16; \$no |bc` printf '%x\n' "1cce446295197a9d6352f9f223a9b698" but it doesn't work for such big number it...

## How to get the negate of decimal to binary?

Hi All, New to this forum (and yes , a newbie in programming..:p) I have a decimal to binary converter script done this way : i=\$1 bit0=\$(( (i & 0x01) > 0 )) bit1=\$(( (i & 0x02) > 0 )) bit2=\$(( (i & 0x04) > 0 )) bit3=\$(( (i & 0x08) > 0 )) bit4=\$((...

## Decimal to BCD (Binary Coded Decimal)

Anybody please help me... Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary Coded Decimal) representation. Also, draw its Flow Chart. This is a unix qn... plz post algorithm for that :confused:

## Converting Binary decimal coded values to Ascii Values

Hi All, Is there any command which can convert binary decimal coded values to ascii values... i have bcd values like below ������������0�-- -v - Pls suggest a way to convert this. Thanks, Deepti.Gaur

## decimal to binary function error

I have the following simple code to return a binary number in a array format given an interger and the number of the bits for specifying the interger as binary number. #include <stdio.h> #include <stdlib.h> int main () { // int* get_binary_number(int* bit_array, int num, int...

## unix script for converting a decimal to binary

Could anybody please help me in writing a script in unix for converting a decimal number to binary number.