在 C# 中将二进制编码的十进制 (BCD) 放入一个字节中

发布于 2024-08-20 06:33:05 字数 146 浏览 6 评论 0原文

我正在努力实现一个协议,它告诉我将 0 到 160 之间的小数放入一个字节中。 我假设,因为它没有指定它想要哪种类型的 BCD,所以我将把一个数字放入低半字节中,将另一个小数放入高半字节中。这意味着我得到 1 个字节,带有两位小数。 但是更大的值如何适合单个字节呢?例如160?

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 fit into a single byte? For example 160?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往昔成烟 2024-08-27 06:33:05

也许它指的是“密集十进制”,我在电信 CDR 格式中使用 BCD 的经验正如您所描述的,其中 99 是可以用单个字节编码的最高十进制。但在维基百科上快速搜索后发现了 DPD。

http://en.m.wikipedia.org/wiki/Densely_Packed_Decimal

Perhaps it is referring to "Densely Packed Decimal" my experience with BCD in a telecommunications CDR format is as you describe, where 99 is the highest decimal that can be encoded in a single byte. But a quick Wikipedia search turned up DPD.

http://en.m.wikipedia.org/wiki/Densely_Packed_Decimal

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文