## 40 bit binary number to BCD

Mathematics, theory and usage in algorithm construction
Kuruku
Posts: 1
Joined: Sat Jul 29, 2023 5:23 pm

### 40 bit binary number to BCD

I have five binary words called W0, W1, W2, W3 and W4. Each word has 8 bit p0 to p7, where p0 is LSB and p7 is MSB. The word W0 is the lowest and W4 is the highest word. All words concatenated together (W0 through W4) represent a 40-bit binary number:
p7(W4) is bit 39 and is MSB of 40 bit binary number
p6(W4) is bit 38
:
:
p1(W0) is bit 1
p0(W0) is bit 0 and is LSB of 40 bit binary number

I need an algorithm, a program to convert this 40 bit number to twelve BCD numbers. each BCD number represents with 4 bit.
BigBlue
Posts: 2
Joined: Sat Jul 15, 2023 7:03 am

### Re: 40 bit binary number to BCD

in first step, you need to convert binary number to decimal number. In the second step you convert decimal number to BCD number. The disadvantage is a latency time because the binary number is too long. Probably best way is to use FPGA and VHDL or Verilog.