如何使用字母二进制符号

发布于 2024-10-01 03:32:48 字数 93 浏览 0 评论 0原文

我正在阅读一篇关于二进制数的文章,最后有一些练习问题,但它没有给出问题的解决方案。最后一个是“需要多少位来表示字母表?”。可以告诉我这个问题的答案并简要解释原因吗? 谢谢。

I was reading an article on binary numbers and it had some practice problems at the end but it didn't give the solutions to the problems. The last is "How many bits are required to represent the alphabet?". Can tell me the answer to that question and briefly explain why?
Thanks.

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

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

发布评论

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

评论(4

暮年 2024-10-08 03:32:48

您只需要 5 位,因为您要数到 26(如果我们只采用大写或小写字母)。 5 位总计为 31,因此您实际上拥有的空间超出了您的需要。你不能使用 4,因为它只能算到 15。

如果你想要大写和小写,那么 6 位就是你的答案 - 6 位会很高兴地算到 63,而你的双字母表又有 (2 * 24 = 48) 个字符留下足够的净空。

You would only need 5 bits because you are counting to 26 (if we take only upper or lowercase letters). 5 bits will count up to 31, so you've actually got more space than you need. You can't use 4 because that only counts to 15.

If you want both upper and lowercase then 6 bits is your answer - 6 bits will happily count to 63, while your double alphabet has (2 * 24 = 48) characters, again leaving plenty of headroom.

一影成城 2024-10-08 03:32:48

这取决于你对字母表的定义。如果要表示 26 个字母的罗马字母表 (AZ) 中的一个字符,则需要 log2(26) = 4.7 位。显然,在实践中,您将需要 5 位。

然而,给定无限的字符流,理论上您可以想出一种接近 4.7 位的编码方案(单个字符和位向量之间不再存在一对一的映射)。

如果您谈论的是代表实际的人类语言,那么由于冗余,您可以使用比这个低得多的数字(在 1.5 位/字符的区域内)。但这太复杂了,无法在这里用一篇文章来讨论……(谷歌关键词是“熵”和“信息内容”)。

It depends on your definition of alphabet. If you want to represent one character from the 26-letter Roman alphabet (A-Z), then you need log2(26) = 4.7 bits. Obviously, in practice, you'll need 5 bits.

However, given an infinite stream of characters, you could theoretically come up with an encoding scheme that got close to 4.7 bits (there just won't be a one-to-one mapping between individual characters and bit vectors any more).

If you're talking about representing actual human language, then you can get away with a far lower number than this (in the region of 1.5 bits/character), due to redundancy. But that's too complicated to get into in a single post here... (Google keywords are "entropy", and "information content").

黎夕旧梦 2024-10-08 03:32:48

字母表中有 26 个字母,因此 2^5 = 32 是包含所有字母的最小单词长度。

There are 26 letters in the alphabet so you 2^5 = 32 is the minimum word length than contain all the letters.

小猫一只 2024-10-08 03:32:48

表达需要有多直接?如果您需要 1:1 且没有翻译层,那么 5 位就可以了。但如果可以选择翻译层,那么您就可以少花钱。例如,摩尔斯电码可以用 3 位来完成。 :)

How direct does the representation need to be? If you need 1:1 with no translation layer, then 5 bits will do. But if a translation layer is an option, then you can get away with less. Morse code, for example, can do it in 3 bits. :)

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