计算机如何将所有内容转换为二进制文件?当他们看到二进制代码时,如何知道它代表数字,单词还是指令? [英] How do computers translate everything to binary? When they see a binary code, how do they know if it represents a number or a word or an instruction?

查看:488
本文介绍了计算机如何将所有内容转换为二进制文件?当他们看到二进制代码时,如何知道它代表数字,单词还是指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道计算机如何将数字转换为二进制.但是我不明白的是,我听说计算机将所有内容(单词,指令等)转换为二进制,而不仅仅是数字.这怎么可能?

I know how computers translate numbers to binary. But what I don't understand is that I've heard that computers translate everything (words, instructions, ...) to binary, not just numbers. How is this possible?

能给我看看一些例子吗?就像计算机如何将字母"A"转换为二进制?

Could you show me some examples? Like how does a computer translate the letter "A" to binary?

当计算机看到二进制代码时,他们如何知道0和1的长字符串表示数字,单词还是指令?

And when computers see a binary code, how can they know if that long string of 0s and 1s represents a number or a word or an instruction?

.

示例:

假设计算机程序员对字母"Z"进行了编码,以便将其转换为以下二进制字符串:11011001111011010111

Let's say that a computer programmer encoded the letter "Z" so that it translates to this binary string: 11011001111011010111

因此,当计算机遇到此二进制字符串时,它将把它转换为字母"Z".

So when the computer will encounter this binary string, it will translate it to the letter "Z".

但是当我们问这台计算机"1259的709的乘积是什么?"

But what happens when we ask this computer "what is the product of 709 by 1259?"

计算机将回答我们"892631".但是,当转换为二进制时,该数字为11011001111011010111.

The computer would answer us "892631". But that number, when translated to binary, is 11011001111011010111.

那么"Z"和"892631"之间有什么区别?

So how would it make a difference between "Z" and "892631"?

.

请注意,我对计算机科学了解不多,所以请用简单的术语进行解释.

Please note that I don't know much about computer science, so please explain everything in simple terms.

推荐答案

计算机实际上并没有将任何内容转换为二进制文件,从一开始就全部为二进制文件,并且计算机从不知道二进制文件.

Computers doesn't actually translate anything to binary, it's all binary from the start, and the computer never knows anything other than binary.

存储在内存中的字符A将为01000001,并且计算机不会将其视为二进制数.当我们要求计算机将该数字作为字符显示在屏幕上时,它将在字体定义中查找它的图形表示形式,以查找其他一些二进制数字以发送到屏幕硬件.

The character A stored in memory would be 01000001, and the computer doesn't see that as anything but a binary number. When we ask the computer to display that number as a character on the screen, it will look up the graphical representation for it in a font definition to find some other binary numbers to send to the screen hardware.

例如,如果计算机是八位Atari,它将在屏幕上找到八个表示字符A的二进制值:

For example if the computer was an eight bit Atari, it would find eight binary values to represent the character A on the screen:

00000000
00011000
00111100
01100110
01100110
01111110
01100110
00000000

如您所见,当图形硬件在屏幕上绘制二进制值时,二进制值将转换为暗像素和亮像素.

As you can see, the binary values would then translate to dark and bright pixels when the graphics hardware would draw it on the screen.

类似地,无论我们对计算机中的数字进行什么处理,都是通过移动二进制值,对二进制值进行计算并将其转换为其他二进制值的所有方式.

Similarly, whatever we do with the numbers in the computer, it's all ways of moving binary values around, doing calculations on binary values, and translating them to other binary values.

例如,如果您使用A的字符代码并将其显示为十进制数字,则计算机将计算出该数字的十进制表示形式是数字6(110)和5(),将其转换为字符6(00110110)和字符5(00110101),然后将其转换为图形表示.

If you for example take the character code for A and want to display it as a decimal number, the computer would calculate that the decimal representation of the number is the digits 6 (110) and 5 (101), translate that to the character 6 (00110110) and the character 5 (00110101), and then translate those into their graphical representation.

这篇关于计算机如何将所有内容转换为二进制文件?当他们看到二进制代码时,如何知道它代表数字,单词还是指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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