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
5
votes
7 answers

Most efficient way to convert BCD to binary

I have the code below to convert a 32 bit BCD value (supplied in two uint halves) to a uint binary value. The values supplied can be up to 0x9999, to form a maximum value of 0x99999999. Is there a better (ie. quicker) way to achieve this? ///…
Andy
  • 5,188
  • 10
  • 42
  • 59
5
votes
2 answers

Self-Complementing Codes (Excess 3, 84-2-1, 2*421)

I'm having a topic here which is from "Number Systems" in the subject of "Introduction to Computer Organisation & Architecture" Then I came across this topic,"Self complementing Codes" There are 3 parts of it which are as follows: i)Excess-3 (I…
Beta Tracks
  • 263
  • 2
  • 5
  • 14
5
votes
9 answers

Converting a int to a BCD byte array

I want to convert an int to a byte[2] array using BCD. The int in question will come from DateTime representing the Year and must be converted to two bytes. Is there any pre-made function that does this or can you give me a simple way of doing…
Roast
  • 1,715
  • 5
  • 24
  • 32
5
votes
5 answers

C# Byte[] to BCD and BCD to INT

I have a Hex file created by CashRegister Machine. I have to read this file in. File uses formatting detailed below. It is like socket packets. Code Data : 2 Byte PLU Code Data: 7 Byte Unit Price Data: 5 Byte Quantity Data: 5 Byte Total Amount Data:…
xFireTR
  • 153
  • 2
  • 2
  • 4
4
votes
1 answer

What do bitshift operations in Intel 8085 assembly do?

I am trying to explain to myself the following 8085 assembly code I have this code that asks for two numbers (from a virtual keyboard within the IDE) and displays them on LEDs 7 and 8: .ORG 0000 CALL DATA MOV C,A CALL PRNT CALL DATA MOV E,A CALL…
Ashir
  • 511
  • 2
  • 8
  • 24
4
votes
1 answer

Assembly Instructions: AAA

I am looking at the pseudo-code: The Hidden Power of BCD Instructions. Here's a snippet of the contents of the website: So, let's take a look at what AAA does. Here is the pseudo-code equivalent (from Intel): IF ((AL AND 0FH) > 9) OR (AF =…
supmethods
  • 525
  • 6
  • 18
4
votes
2 answers

Java code or lib to decode a binary-coded decimal (BCD) from a String

I have a string consisting of 1's ('\u0031') and 0's('\u0030') that represents a BCD value. Specifically, the string is 112 characters worth of 1's and 0's and I need to extract either 8 or 16 of these at a time and decode them from BCD to…
T to the J
4
votes
2 answers

BCD to Decimal And Decimal to BCD

I am writing a library for RTC module in Arduino where the data is stored in BCD. I know how the Decimal number is converted into BCD but having some problem while writing it programmatically. After searching the internet I got two formulas which…
Himadri Ganguly
  • 715
  • 4
  • 11
  • 31
4
votes
1 answer

packed decimal to ascii assembly

I'm trying to convert packed decimal numbers into ascii strings. Here is my understanding thus far: The following: bcd BYTE 34h Should convert to the decimal number 34 after being "unpacked". Now I'm not sure on the best way of doing this. If I…
Dalton Conley
  • 1,599
  • 2
  • 28
  • 36
4
votes
2 answers

Unpack Mainframe packed Decimal (BCD) with PHP

I got an data file from a mainframe. I handled already the EBCDIC conversion to latin1 with PHP. But now are this packed decimal fields left. For examle the number 12345 is packed into 3 Bytes and looks like: x'12345C' Negative would be like:…
Andi S.
  • 317
  • 1
  • 11
4
votes
4 answers

Why is the double-dabble algorithm working?

I am trying to understand why the double-dabble algorithm is working, but I am not getting it. There are a lot of great descriptions of the steps and the purpose of the algorithm,…
Michael Palm
  • 337
  • 5
  • 16
4
votes
4 answers

Algorithm to convert a String of decimal digits to BCD

I am looking a way to convert a string to BCD equivalent. I use Java, but it is not a question of the language indeed. I am trying to understand step by step how to convert a string to BCD. For example, suppose I have the following string; "0200"…
Nico
  • 374
  • 2
  • 4
  • 17
4
votes
3 answers

Convert datatype ftFloat to ftBCD

How can I convert a fieldtype from ftFloat to ftBCD; I tried for i := 0 to FDataSet.FieldCount - 1 do begin if FDataSet.Fields.Fields[i].DataType = ftFloat then begin FDataSet.Fields.Fields[i].DataType := ftBCD; …
CiucaS
  • 2,010
  • 5
  • 36
  • 63
4
votes
1 answer

Converting Negative numbers with TADOQuery

I have a huge problem with TADOQuery: This is my SQL: select cast(-10 as number(9)) foo, -10 bar from dual Instead of TBCDField, a TIntegerField will be created when you add the "foo" field, because the type is changed at this point: procedure…
EProgrammerNotFound
  • 2,403
  • 4
  • 28
  • 59
3
votes
3 answers

Where can I find a free or open source C++ library to do BCD math?

Where can I find a free or open source C++ library to do Binary Coded Decimal math?
Richard Brightwell
  • 3,012
  • 2
  • 20
  • 22
1
2
3
12 13