Questions tagged [bcd]

A binary-coded decimal (BCD) is a method of representing each decimal digit of a number with a fixed number of bits.

Though binary-coded decimal is less efficient memory-wise than 2's complement there are some advantages that result in BCD still being in use today, particularly in databases and applications where monetary and similarly sensitive data types are stored and manipulated.

194 questions
2
votes
1 answer

How to convert decimal back BCD?

I am able to convert BCD to decimal, for example I can convert 0x11 to 11 instead of 17 in decimal. This is the code I used. unsigned char hex = 0x11; unsigned char backtohex ; int dec = ((hex & 0xF0) >> 4) * 10 + (hex & 0x0F); Now I want to…
Ammar
  • 1,203
  • 5
  • 27
  • 64
2
votes
2 answers

Self-Made BCD Class - Multiplying BCDs Error

I am making a BCD class as an exercise for school, and am encountering some issues. Below is my BCD class. My problem is with the multiplyBCDs method. It works fine with smaller numbers such as 4,329 * 4, however, with larger products, such as the…
swallow
  • 23
  • 4
2
votes
5 answers

COBOL COMP-3 number format issue

I have a cobol "tape format" dump which has a mixture of text and number fields. I'm reading the file in C# as a binary array (array of byte). I have the copy book and the formats are lining up fine on the text fields. There are a number of…
Shaun Neal
  • 1,183
  • 1
  • 10
  • 12
2
votes
4 answers

How is BCD format used in programming?

Excuse me if you find it silly. I am not able to understand the purpose of BCD and its implementation in programming? What I so far understand about BCD is that it is an internal way of data representation in a byte or a nibble. In a simple C…
KawaiKx
  • 9,558
  • 19
  • 72
  • 111
2
votes
1 answer

C++ from char array to BCD

Arduino project using the 'Arduino language' (C++ wrapper) - I have an 8-char array which gives 24Hr clock in the form {'H','H',':','M','M',':','S,'S'} and I need to convert this to BCD. I thought I understood the idea well enough but I get an…
Harry Lime
  • 2,167
  • 8
  • 31
  • 53
2
votes
1 answer

binary coded decimals (BCD) put into a byte in C#

I'm working on implementing a protocol tha tells me to put decimals from 0 to 160 into a single byte. I assume, since it doesn't specify what sort of BCD it wants, that I am to put one digit into the lower nibble and the other decimal into the…
John
  • 3,591
  • 8
  • 44
  • 72
2
votes
2 answers

auxiliary flag in X86 processor

The auxiliary flag becomes set when the lower nibble produces a carry to the higher order nibble. For example: 1001 9 1001 9 ---- ---- 1 0010 18 In this case the axillary carry is set. I also heard that this carry is used to add 0110 to…
Danny
  • 85
  • 1
  • 5
2
votes
2 answers

Verilog multiple drivers

I'm trying to make BCD Counter using Verilog that will be connected to 7-segment decoder.After I synthesize it, the error occured like this: Multi-source in Unit on signal >; this signal is connected to multiple drivers.>**And…
user3110542
  • 29
  • 1
  • 2
  • 6
2
votes
1 answer

Track2 in BCD - 'D' character

I'm supposed to send Data-Element 35 (Track2: ".....=.....") in BCD format. The '=' character is to be replaced with a 'D'. Isn't 0x0D illegal in BCD? But, the customer is always right... so, how can it be done? I can add the following static…
Rami Rosenbaum
  • 467
  • 5
  • 18
2
votes
1 answer

Convert hex to BCD in python

my hex string is 0e0010000001020c93b2 its equivalent BCD string(online generator) is 01100110000100010100001010000011011010000001011010000011100101101001000110000100011010010000 How can I do it python?
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
2
votes
2 answers

Converting six-bit binary number to it's corresponding two digit BCD number?

Here is the question that I tried so hard but I couldn't solve it. I captured the question as it was from the question-paper, I couldn't solve it in the exam, and non of student's could. You probably ask, why don't you ask your lecturer ( it's fair…
Caffe Latte
  • 1,693
  • 1
  • 14
  • 32
1
vote
2 answers

Why is BCD = Decimal in PLC?

This question is derived from my previous SO question's commends. I am confused with PLC's interpretation of BCD and decimal. In a PLC documentation, it somehow implies BCD = decimal: The instruction reads the content of D300, 0100, as BCD. …
KMC
  • 19,548
  • 58
  • 164
  • 253
1
vote
1 answer

Printing a packed BCD (DT) - assembly language (TASM)

I tried to make a simple calculator in assembly. I used TASM(school policy). The problem is printing a number saved with FBSTP command(co-processor command) in a DT variable. FBSTP adr - Stores at the address „adr” the value located on top of…
Vlad Topala
  • 896
  • 1
  • 8
  • 34
1
vote
1 answer

VHDL BCD to 7 Segment Display

I'm very new to VHDL and there is a problem I can't quite get my head around. I am trying to display a 12 bit BCD onto 3 7-segment displays. However, I am at a lost on how to split the 12 bit BCD into 3 digits. I am using this tutorial as a guide…
MikeMania
  • 5
  • 1
  • 5
1
vote
0 answers

Compressing 5 Bytes into 4 Bytes

I am trying to understand more about BCD, packed/unpacked byte arrays and byte shifting, in this picture I made an example of the instructions which I am unsure about, an array of 5 bytes is being compressed or packed into an array of 4 bytes, and…
Se7en Axis
  • 59
  • 5