第三次作业
第一部分-计算
Write out variables x, y and z in binary code
- int8_t x = 67; int8_t y = -7; int8_t z = y - x;
x = 0100 0011, y = 1111 1001, z = 1011 0110 - int8_t x = 0xd3;
x = 1101 0011 存在溢出错误 - uint8_t = 0xd3;
x = 1101 0011 - int8_t x = 127; int8_t y = -7; int8_t z = y – x;
x = 0111 1111, y = 1111 1001, z = 0111 1010 存在溢出错误 - float x = 1.125;
x = 0 01111111 00100000000000000000000 - float x = 23.0;
x = 0 10000011 01110000000000000000000 - float x = 0.45;
x = 0 01111101 11001100110011001100110 存在精度误差第二部分-名词解释
-
Method of complements:
In mathematics and computing, the method of complements is a technique used to subtract one number from another using only addition of positive numbers. This method was commonly used in mechanical calculators and is still used in modern computers.
在数学与计算中,补码法是一种只用正数的加法来实现一个数减去另一个数的技术。这种方法普遍被运用于计算器并且任然被用于现代计算机中。 - Byte:
The byte is a unit of digital information that most commonly consists of eight bits, representing a binary number. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit of memory in many computer architectures.
字节是数据信息的一个单元,通常由八位比特组成,用于表示二进制数。在历史上,字节是用来编码计算机中单个文本字符的比特数,因此它是许多计算机体系结构中最小的可寻址存储单元。 - Integer:
In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware, including virtual machines, nearly always provide a way to represent a processor register or memory address as an integer.
在计算机科学中,整数是整数数据类型的基准,一种表示数学整数范围的数据类型。整数数据类型可以是不同的大小,并且可以允许或不允许包含负值。分组的大小不同,因此不同类型的计算机之间可用的整数大小集合也不同。计算机硬件,包括虚拟机,几乎总是提供将处理器、寄存器或存储器地址表示为整数的方法。 - Floating-point arithmetic:
In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation so as to support a trade-off between range and precision. For this reason, floating-point computation is often found in systems which include very small and very large real numbers, which require fast processing times.
在计算中,浮点算法是使用实数的公式表示作为近似以支持范围和精度之间的权衡的算法。因为这个原因,浮点运算经常出现在包含非常小和非常大的实数的系统中,这需要快速的处理时间。
第三部分-证明
-
任意一个正二进制数B
-B = 2^k-B = 2^k - 1 - B + 1 = (11111…111 - B) + 1 ;
只要K足够大,括号部分就为B取反,因此B的负数的二进制形式即B取反加一 -
x的二进制形式为 11110001,再转化为八进制为0361
-
x = 0xE1 ,y = 0xFFE1;
八位的x被转换为2字节(或4字节)的变量并赋值给y;
因为是负数,在转化时高位置1因此x到y的转化为11100001变为1111111111100001。 -
NaN解释如下:
In computing, NaN, standing for not a number, is a numeric data type value representing an undefined or unrepresentable value, especially in floating-point calculations. Systematic use of NaNs was introduced by the IEEE 754 floating-point standard in 1985, along with the representation of other non-finite quantities like infinities.
Two separate kinds of NaNs are provided, termed quiet NaNs and signaling NaNs. Quiet NaNs are used to propagate errors resulting from invalid operations or values, whereas signaling NaNs can support advanced features such as mixing numerical and symbolic computation or other extensions to basic floating-point arithmetic. For example, 0/0 is undefined as a real number, and so represented by NaN; the square root of a negative number is imaginary, and thus not representable as a real floating-point number, and so is represented by NaN; and NaNs may be used to represent missing values in computations.