解析两个数字 - 上位和个位

Parse two numbers - upper digit and unit digit

我想解析两个数字。 我从 RTC IC 得到 7 位,其中第 6、5、4 位是高位数字(秒数的第一个数字 0 - 5),第 3、2、1、0 位是单位数字(0 - 9)。现在我想创建一个函数来解析这两个数字和 return 秒数。

这是我从 RTC IC 获得的第二个数字的 table。

对于第一个数字,我屏蔽了这些位,得到了上限和下限数字。我想从函数中解析这两个数字和 return 它们。 如何?

非常简单,只需按照记录拆分位即可:

uint8_t i = getBcd();
return (i >> 4 & 0x7) * 10 + (i & 0xf);
namespace SOExample
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // TODO: Implement Functionality Here
            byte ourByte = 89;

            int units = ourByte & 15;
            int tens = ourByte >> 4;

            int result = (int) (tens * 10 + units);


            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}