ASCII代码的排序后是否有任何逻辑? [英] Is there any logic behind ASCII codes' ordering?

查看:73
本文介绍了ASCII代码的排序后是否有任何逻辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我的弟弟学习工程学C.我向他解释了如何在内存中实际存储不同的数据类型.我向他解释了带符号/无符号数字和十进制数字浮点数背后的原因.当我告诉他有关C语言中char类型的信息时,我还带领他学习了ASCII码系统,以及如何将char也存储为1个字节的数字.

I was teaching C to my younger brother studying engineering. I was explaining him how different data-types are actually stored in the memory. I explained him the logistics behind having signed/unsigned numbers and floating point bit in decimal numbers. While I was telling him about char type in C, I also took him through the ASCII code system and also how char is also stored as 1 byte number.

他问我,为什么给'A'分配了ASCII码65,而没有别的?同样,为什么给'a'专门指定代码97?为什么大写字母和小写字母之间存在6个ascii码的间隔?我对此一无所知.您能否帮助我理解这一点,因为这也给我带来了很大的好奇心.到目前为止,我还没有找到任何讨论该主题的书.

He asked me why 'A' has been given ascii code 65 and not anything else ? Similarly why 'a' is given the code 97 specifically ? Why there's a gap of 6 ascii codes between the range of capital letters and small letters ? I had no idea of this. Can you help me understand this, since this has created a great curiosity to me as well. I've never found any book so far that has discussed this topic.

这是什么原因? ASCII代码是否逻辑组织?

What is the reason behind this ? Are ASCII codes logically organized ?

推荐答案

有历史原因,主要是为了使ASCII代码易于转换:

There are historical reasons, mainly to make ASCII codes easy to convert:

数字(0x30至0x39)具有二进制前缀110000:

Digits (0x30 to 0x39) have the binary prefix 110000:

0 is 110000
1 is 110001
2 is 110010

等 因此,如果删除前缀(前两个"1"),则最终会得到二进制编码的十进制数字.

etc. So if you wipe out the prefix (the first two '1's), you end up with the digit in binary coded decimal.

大写字母的二进制前缀为1000000:

Capital letters have the binary prefix 1000000:

A is 1000001
B is 1000010
C is 1000011

等 同样,如果删除前缀(第一个"1"),则会得到字母索引字符(A为1,Z为26,依此类推).

etc. Same thing, if you remove the prefix (the first '1'), you end up with alphabet-indexed characters (A is 1, Z is 26, etc).

小写字母的二进制前缀为1100000:

Lowercase letters have the binary prefix 1100000:

a is 1100001
b is 1100010
c is 1100011

等 与上述相同.因此,如果在大写字母后面加上32(100000),则表示为小写版本.

etc. Same as above. So if you add 32 (100000) to a capital letter, you have the lowercase version.

这篇关于ASCII代码的排序后是否有任何逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆