计算机如何识别给定数字为"Two's comeplent"形式? [英] How does the computer recognise that a a given number is in its Two's comeplent form?

查看:113
本文介绍了计算机如何识别给定数字为"Two's comeplent"形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解二进制补码"是什么,以及它的用处.我想知道的是,计算机如何确定该数字采用二进制补码形式?

I understand what the Two's complement is and what it is useful for. What I'd like to know is how does the computer decide that the number is in its Two's complement form?

如何以及何时确定1111 1110是-2而不是254?是在操作系统的处理级别上吗?

How and when does it decide that 1111 1110 is -2 and not 254? Is it at the OS level of processing?

推荐答案

计算机将已经期望数据采用二进制补码形式(或不采用二进制补码形式)(否则将无法确定数据是否为二进制形式). -2或254).是的,这可能会在操作系统级别上决定.

The computer will already be expecting the data to be in (or not in) two's complement form (otherwise there wouldn't be a way of telling if it is - 2 or 254). And yes, that would probably be decided at the OS-level.

在高级编程语言中声明变量时,您可能可以将其与设置变量类型时使用的想法相提并论.例如,您很有可能将类型设置为十进制"或整数",然后编译器将期望值坚持该类型.

You can probably relate this to the same kind of idea used when setting variable types when declaring variables in a high-level programming language; you'll more than likely set the type to be "decimal", for example, or "integer" and then the compiler will expect values to stick to this type.

这篇关于计算机如何识别给定数字为"Two's comeplent"形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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