x30是什么意思? [英] What is the meaning of x30?

查看:395
本文介绍了x30是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习C/C ++几个星期.我最近读了一篇有关printf()的文章;功能.这是前几行:

在早期,计算机程序员会
编写自己的子例程以读取和打印
数字.实际上,这并不困难.只是
分配一个字符数组来保存结果,除
将数字减十,保留其余部分,然后在
中添加 x30 并将其存储在数组的末尾.重复
处理直到找到所有数字.然后打印.
太简单了吧?"(*)

谁能为我解释以上方法?
我尝试使用Google搜索,但除了NASA的飞机外什么也没找到!

谢谢.

[*本段摘自[printf的秘密] Don Colton教授.]

I am studying C/C++ for a few weeks. I recently read an article about printf(); function. Here is the first few lines :

"In the early days, computer programmers would
write their own subroutines to read in and print out
numbers. It is not terribly difficult, actually. Just
allocate a character array to hold the result, divide
the number by ten, keep the remainder, add x30 to
it, and store it at the end of the array. Repeat the
process until all the digits are found. Then print it.
Too easy, right?"(*)

Can anyone explain the above method for me?
I tried googling it but found nothing except a jet from NASA!

Thanks.

[*This paragraph is copied from [secrets of "printf"] Professor Don Colton.]

推荐答案

在早期,人们使用7位编码.这是ASCII码.此编码中的第一个代码是控制代码,要显示的数字从 30h 开始.因此,要显示一个数字(例如01h),您必须添加30h才能在屏幕上以数字形式看到它,而不是控制符号或其他符号.
In early days 7 bit encoding was used. It was ASCII. The first codes in this encoding are control codes, and digits to display are starting from 30h. So to display a number (01h for example) you have to add 30h to see it on the screen as a digit, not a control sybol or something else.


"x"表示后面的数字不是十进制(以10为底),而是十六进制(以16为底)".
因此,"x30"为30十六进制,即十进制为48.

在这种情况下,它使用"x30"作为值,将数字零转换为字符"0",将数字转换为字符"1",依此类推,因为x30是字符的ASCII(和UNICODE)值``0''
The "x" means "the number that follows is not in Decimal (base 10) but in Hexadecimal (base 16)".
So "x30" is 30 Hex, or 48 in decimal.

In this case it is using "x30" as a value which converts the number zero to the character ''0'', one to ''1'' and so on, becasue x30 is the ASCII (and UNICODE) value for the character ''0''


这篇关于x30是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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