Using Java, I need to convert a decimal to a packed BCD and back (packed BCD to Decimal), if possible, signed or unsigned. Can you help? I am hoping that there might be some open source software out here that I could work from. Would you know of any available open source that does this?
My God, someone asking about BCD. Next it'll be how to solve polynomials with VAX microcode. It looks like there's no free code anywhere, as far as I can tell, except for a small example in C called Jon's BCD Clock. It does unsigned-to-BCD only.
Scratching my head, it sounds pretty simple though. A DECIMAL type is probably implemented (for you) as a BigDecimal....
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
You can toString() that type. Once you've got a string, you're most of the way to BCD. Take each character, subtract "0" and stuff the result in a byte of a byte array. For signed numbers, that's a trickier proposition and depends on the packed format; I don't recall any signed BCD formats offhand.