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
1
vote
2 answers

multiplying two two digit numbers with both the numbers taken as input and result is also to be printed in Tasm

i am not understanding as to what can be done in this case single digit multiplication was possible using the AAM instruction however for AAM you need unpacked BCD therefore the result after two digit multiplication wont be accumulated in the AX…
Denson
  • 121
  • 1
  • 2
  • 11
1
vote
2 answers

Storing a string as a binary string of 'unsigned char's to in matters of compression

I need to store a string of 8 chars (they're all digits) in a compressed method, As I understand it, each char uses 8 bits which are 1 byte and since I only use digits I can use 4 bits (2^4=16 combinations) so for each unsigned char I can store two…
Quaker
  • 1,483
  • 3
  • 20
  • 36
1
vote
3 answers

Unpacking AS400 packed decimal (BCD) - possibly borked by EBCDIC conversion?

I'm getting files transferred from an AS/400 to our Windows (SBS 2003) via FTP. The files are fixed-width data. The text appears fine, but some of the fields are packed decimals, which when unpacked give bad values. My assumption is that there's…
Dave
  • 11
  • 1
  • 2
1
vote
1 answer

Binary coded decimals in verilog

I wrote the following code for BCD to seven segment. The code compiles find and simulates too but the value of num is not going beyond 2. I don't know why is that. Here is the code: module BCDtoSeven_TOP reg [3:0] num; wire a,b,c,d,e,f,g; …
Alfred
  • 1,543
  • 7
  • 33
  • 45
1
vote
2 answers

BCD arithmetic operations

I have written a function that converts a double to a BCD (BCD: Save each digit of the double as an unsigned char, in addition save the complete length, the fractional length (part behind the floating point) and the sign of the double number). I use…
Kossi
  • 21
  • 1
  • 4
1
vote
2 answers

What is meant by BCD16

I'm writing an Ama file generating simulator. In the Ama specifications, it gives the number of bytes(not bits) for a field as BCD16, BCD12 etc(BCD{a number}). For fields with BCD16 the actual length is 8 bytes. Can anyone please tell me what that…
Prasad Weera
  • 1,223
  • 3
  • 13
  • 25
1
vote
2 answers

How to convert a float to BCD

How can I convert a positive float (ieee 754, single precision 32 bit) to BCD in C#? UPDATE If I'm not wrong, what I need is called packed BCD. I'm already doing int to BCD conversions. In the way I'm doing, the number 1234 would result in the…
Fernando
  • 4,029
  • 1
  • 26
  • 35
0
votes
1 answer

A computer represents information in groups of 64 bits. How many different integers can be represented in BCD code?

This from my Interview-MCQ module: A computer represents information in groups of 64 bits. How many different integers can be represented in BCD code? The given answer is 1016, however no explanation is provided, I was just wondering if somebody…
Quixotic
  • 2,424
  • 7
  • 36
  • 58
0
votes
1 answer

What kind of binary numeric representation is this?

I have these numbers from an old database file and I'm looking for the numeric representation this uses. The numbers are stored as binary format, and they're supposedly 64-bit floating numbers, something like: 54.123 and so on. I'm posting only…
Opi
  • 1,288
  • 1
  • 10
  • 14
0
votes
2 answers

Why is 0xF used for bitwise operations involving conversions from BCD values to integers?

This may be a really dumb question, but why is 0xF used in the bitwise operations when converting from a BCD values to an integer. I understand that 0xF represents something like 0x15, which is equal to 00010101 in binary. However, why is this…
0
votes
1 answer

BCD Calculator issue

I am converting a hex 0xE0 to BCD. When I do this I am getting back a 64. I know this is completely wrong and maybe it's something in my C++ code, but 64 just doesn't sound correct. Any ideas? Is 0xE0 a special case? (0xE0 is 224 in decimal.) Here…
Questioneer
  • 761
  • 4
  • 12
  • 20
0
votes
0 answers

Convert Densely-packed BCD to decimal in javascript

The function below converts from decimal to densely-packed BCD. I need help in reverse engineering this function that converts it from densely-packed BCD to decimal in JavaScript. However, it would not produce correct results for 3 or more decimal…
alxyzzles
  • 1
  • 2
0
votes
0 answers

Incorrect results subtracting 1 from 100 working with a string of ASCII digits

section .bss num: resb 3 section .text global _start _start: ; Read input mov eax, 3 mov ebx, 0 mov ecx, num mov edx, 3 int 80h sub byte [num+2], 1 cmp byte [num+2], 255 jne skip_borrow sub byte [num+1], 1 cmp byte…
Ki Kim
  • 1
  • 1
0
votes
0 answers

A program that multiplies "two numbers" written in a spaced BCD format. in assembly

i was trying to answer this assembly question and I couldn't understand what to do Here is a program that multiplies "two numbers" written in BCD format with a space. DATA SEGMENT NUM1 DB 3, 9 NUM2 DB 9 RESULT DB 0, 0, 0 DATA…
Hartk
  • 9
  • 3
0
votes
1 answer

Why does this error in indexing BCD adder appear?

I am not sure, what exactly the error is. I think, my indexing in the for-loop is not Verilog-compatible, but I might be wrong. Is it allowed to index like this (a[(4*i)+3:4*i]) in a for-loop just like in C/C++? Here is a piece of my code, so the…