bcd

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? /// <summary> /// Convert two PLC words in BCD format (forming 8 digit number) into sin...

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 decimal. Ideas? Packages? Libs? Code? Snooty remarks about my sheer fucking laziness? All is welc...

Convert really big number from binary to decimal and print it

I know how to convert binary to decimal. I know at least 2 methods: table and power ;-) I want to convert binary to decimal and print this decimal. Moreover, I'm not interested in this `decimal'; I want just to print it. But, as I wrote above, I know only 2 methods to convert binary to decimal and both of them required addition. So, I'...

Decimal to BCD conversion

I know you can use this table to convert decimal to BCD: 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 Is there a equation for this conversion or you have to just use the table? Im trying to write some code for this conversion but Im not sure how to do the math for it. Suggestions?...

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 an implicit EBCDIC->ASCII conversion happening, which is converting the packed bytes too. ...

does .net provides api to convert ascii to bcd?

Platfrom 3.5 .net.(c#) please refer me to code which converts ascii to bcd (c#). ...

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

Hi 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 higher nibble. Meaning I get 1 byte with a two-digit decimal. But how would any larger value...

Assembler : why BCD exists?

Hello, I know BCD is like more intuitive datatype if you dont know binary. But I dont know why to use this encoding, its like dont makes a lot os sense since its waste representacion in 4bits (when representacion is bigger than 9). Also I think x86 anly supports adds and subs directly (you can convert them via FPU). Its possible that t...

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 this? example: int year = 2010 would output: byte[2]{0x20, 0x10}; ...

Java : Best way to convert a BigDecimal to BCD bytes

Hi All, I have a BigDecimal currency value that needs to be converted to a 6 byte BCD value in cents with leading zeros for a lower level protocol I'm interfacing with. Anyone have any cunning implementations for doing this? TIA, Fred ...

BYTE BCD to ASCII conversion optimization

hello all, I've written a function in c that converts a byte (unsigned char) BCD string into ASCII. Please have look at the code and advice some improvements. Is there any other efficient way that can convert BYTE BCD to ASCII. BYTE_BCD_to_ASC(BYTE *SrcString, char *DesString) { switch (((BCD *)SrcString)->l) { ...

BCD arithmetics

Where can I find a good BCD arithmetics library for c or c++? ...