Converting a int to a BCD byte array

Posted by Lily on Stack Overflow See other posts from Stack Overflow or by Lily
Published on 2010-03-15T15:32:43Z Indexed on 2010/03/15 15:39 UTC
Read the original article Hit count: 471

Filed under:
|
|
|

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};

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET