gpt4 book ai didi

c# - 如何从以下字节中提取日期时间?

转载 作者:行者123 更新时间:2023-11-30 20:39:27 26 4
gpt4 key购买 nike

我在附加图像中有以下 5 个字节,需要从中提取日期时间。我知道我需要位移位,可能会使用按位与,但无法从字节中获取正确的信息。

enter image description here

最佳答案

也许是这个?

int yearBase = 1993;

int year = yearBase + (int) ((bytes[4] & 0xF0) >> 4) | ((bytes[3] & 0xE0) >> 1);
int month = (int) (bytes[4] & 0x0F);
int day = (int) (bytes[3] & 0x1F);
int hour = (int) ((bytes[2] & 0xF8) >> 3);
int min = (int) (((bytes[2] & 0x03) << 3) | ((bytes[1] & 0xE0) >> 5));
int sec = (int) ((bytes[1] & 0x1F) << 1) | ((bytes[0] & 0x80) >> 7);
int hundreths = (int) (bytes[0] & 0x7F);

关于c# - 如何从以下字节中提取日期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34344962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com