3 位编码 = 八进制; 4 位编码 = 十六进制; 5 位编码 =?

发布于 2024-11-04 04:08:07 字数 133 浏览 6 评论 0原文

是否有一种编码以 5 位为一组来编码二进制数据?

AZ 包含 26 个字符,0-9 包含 10 个字符。总共 36 个字符足以进行 5 位编码(仅 32 种组合)。

为什么我们不使用 5 位编码而不是八进制或十六进制?

Is there an encoding that uses 5 bits as one group to encode a binary data?

A-Z contain 26 chars and 0-9 contain 10 chars. There are totally 36 chars which are sufficient for a 5-bit encoding (32 combinations only).

Why don't we use a 5-bit encoding instead of Octal or Hexadecimal?

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

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

发布评论

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

评论(3

一口甜 2024-11-11 04:08:07

正如@S.Lott 的评论中提到的,当紧凑性很重要时,base64(6 位)通常用于将二进制数据编码为文本。

出于调试目的(例如十六进制转储),我们使用十六进制,因为字节的大小可以被 4 位整除,因此每个字节都有一个唯一的 2 位十六进制表示,无论其周围有什么其他字节。这使得在查看十六进制转储时很容易“看到”各个字节,并且在 8 位二进制和 2 位十六进制之间进行心理转换也相对容易。 (在 base64 中,字节和编码字符之间没有 1:1 对应关系;同一字节可以根据其位置和其他相邻字节的值生成不同的字符。)

As mentioned in a comment by @S.Lott, base64 (6-bit) is often used for encoding binary data as text when compactness is important.

For debugging purposes (e.g. hex dumps), we use hex because the size of a byte is evenly divisible by 4 bits, so each byte has one unique 2-digit hex representation no matter what other bytes are around it. That makes it easy to "see" the individual bytes when looking at a hex dump, and it's relatively easy to mentally convert between 8-bit binary and 2-digit hex as well. (In base64 there's no 1:1 correspondence between bytes and encoded characters; the same byte can produce different characters depending on its position and the values of other adjacent bytes.)

锦爱 2024-11-11 04:08:07

是的。它是 Base32。也许这个名字是Triacontakaidecimal,但它太长而且很难记住,所以人们简单地称之为base 32。同样,还有用于 6 位组的 Base64

Base32 比十六进制和 base64 的使用要少得多因为与 Base64 相比,它浪费了很多空间,并且与十六进制(可以被 8、16、32 或 64 整除)相比,它使用奇数位数。 6 也是偶数,因此在二进制计算机上比 5 更好

Yes. It's Base32. Maybe the name would be Triacontakaidecimal but it's too long and hard to remember so people simply call it base 32. Similarly there's also Base64 for groups of 6 bits

Base32 is much less common in use than hexadecimal and base64 because it wastes to much space compared to base64, and uses an odd number of bits compared to hexadecimal (which is exactly divisible by 8, 16, 32 or 64). 6 is also an even number, hence will be better than 5 on a binary computer

(り薆情海 2024-11-11 04:08:07

当然可以,为什么不呢:

Welcome to Clozure Common Lisp Version 1.7-dev-r14614M-trunk  (DarwinX8664)!
? (let ((*print-base* 32)) (print 1234567))
15LK7 
1234567
? (let ((*print-base* 32)) (print (expt 45 19)))
KAD5A5KM53ADJVMPNTHPL 
25765451768359987049102783203125
? 

Sure, why not:

Welcome to Clozure Common Lisp Version 1.7-dev-r14614M-trunk  (DarwinX8664)!
? (let ((*print-base* 32)) (print 1234567))
15LK7 
1234567
? (let ((*print-base* 32)) (print (expt 45 19)))
KAD5A5KM53ADJVMPNTHPL 
25765451768359987049102783203125
? 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文