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
0
votes
1 answer

Hexa to BCD conversion

I have the HEXA String as 7E2466490CE1A430 which I am converting into BCD and sending this value from a TCP client program. String message = "7E2466490CE1A430"; byte[] result = Hex.decodeHex(message); Socket socket =…
0
votes
1 answer

Can somebody help me to revert this STR to BCD function?

I struggling to convert back the BCD to STR, if anyone quickly knows how to do it I really appreciate it. Public Function strBCDToStr(ByVal shIn As Short) As String 'BCD to Text Dim m_strTemp As String = "" For m_iLoop As Integer = 1 To…
No hay Problema
  • 853
  • 1
  • 10
  • 14
0
votes
1 answer

Storing to memory - BCD or binary?

If an X86_64 machine save a integer 56 will that be stored in the memory cells as binary 00111000 or BCD 01010110?
Franc
  • 319
  • 9
  • 28
0
votes
1 answer

How do I do a BCD to unsigned integer conversion in vhdl or Labview

I am programming an application in vhdl for a National Instruments CompactRio. One of the inputs is from a scale that only outputs an ASCII string of the weight on the scale. I know I can convert the ASCII digits to Binary Coded Decimal simply by…
user435050
  • 23
  • 4
0
votes
1 answer

Verilog Binary Coded Decimal Adder Not Outputting Correctly

I'm new to Verilog and basically trying to teach myself a Digital Logic Design module for university. I am trying to write a BCD Adder in Verilog using two Full Adders with some logic in between for conversion to BCD when needed. Here is my…
0
votes
1 answer

Why auxiliary flag is 0 when there is a borrow between nibbles

Testing on EMU8086, with the following code snippet: MOV CX, 1527H SUB CX, 44H The emulator shows that AF is 0 1527 - 44 ======== 14E3 When doing the subtraction by hand, we got 7 - 4 = 3, no problem here. Then 2 - 4, we then have to…
Youssef13
  • 3,836
  • 3
  • 24
  • 41
0
votes
1 answer

6502 assembly binary to bcd - is that possible on x86?

I have a few questions regarding this code: ; Convert an 16 bit binary value to BCD ; ; This function converts a 16 bit binary value into a 24 bit BCD. It ; works by transferring one bit a time from the source and adding it ; into a BCD value that…
user13385400
0
votes
1 answer

how to do aaa instruction in assembly to number bigger than 99

i work on assembly for the X86 platform and i got an issue with doing bcd for numbers bigger than 99. i got in 'AX' 123 (decimal) and i added to it 5 (decimal) then i did 'aaa' but instead of the result to be 128 its 0106. i saw the algorithm and…
0
votes
0 answers

Numpy Numpty - HexBytes to String Literal

I fromfile using a structured dtype and have one field that is raw hexbytes ('V2) - it looks like this: [[b'\x00\x00', b'\x05\x01', b'\x00\x00', b'\x00\x00', b'\x00\x00' .....], ... [b'\x00\x00', b'\x05\x01', b'\x00\x00', b'\x00\x00', b'\x00\x00'…
0
votes
2 answers

Delphi 10.4 fails to show decimal(5,2) BCD fields on DBGrids if there also is a datetime field

When I have a ClientDataset with datetime fields and decimal(5,2) fields, Delphi 10.4 can't show them on a TDBGrid, it raises a convert exception. I have prepared an small test project to show this error (my real data comes from SQL Server, although…
Marc Guillot
  • 6,090
  • 1
  • 15
  • 42
0
votes
0 answers

Translating an Int to a BCD byte array

Joel answered on Sep 2, 2016: Public Shared Function ToBcd(ByVal pValue As Integer) As Byte() If pValue < 0 OrElse pValue > 99999999 Then Throw New ArgumentOutOfRangeException("value") Dim ret As Byte() = New Byte(3) {} 'All bytes are init…
Raimund
  • 9
  • 4
0
votes
1 answer

How to convert a string to byte array in bcd format in java?

I have the next string: String points = "210987654321"; and I need to end up in the 6 byte array in bcd format which looks like this (same digits): byte [] result = { 0x21, 0x09, (byte) 0x87, 0x65, 0x43, 0x21 }; How do I get there?…
IKo
  • 4,998
  • 8
  • 34
  • 54
0
votes
0 answers

uart sending in 8051

In uart, I tried to sent in some numbers that Itried to convert to bcd and then to send. The code works only from 00 to 99, if I want to send something bigger then 99 it will convert it to an ASCI table to some char or different number. Could you…
Daniel shutov
  • 11
  • 1
  • 4
0
votes
3 answers

(JAVA) convert decimal to Binary coded decimal?

For example, I would like to convert the int value 12 into a String output of BCD: 00 12 (0x00 0x12). If I have int value of 256, it will be 02 56 (which is 0x02 0x56), or if I have a int value of 999, it will be 09 99 (0x09 0x99), 9999 would be 99…
user5793598
0
votes
0 answers

Doing 198-43 in BCD

To solve this I took the 10s complement of 43, which is 57. Then I tried to add the BCD values of 57 and 198 like this: The right answer is 155 but I got 255. Pretty sure the carry is the problem. I'm not sure what to do with the carry. I've seen…