Arithmetic
之前就听说计算机只会做加法运算, 其余运算都是通过演化而来的, 这次在看
Computer can do add arithmetic only, other arithmetics are based on it.
add
加法要注意一下溢出, 可以参考一下我之前的笔记
the key point of add arithmetic is overflow, about overflow
Sub
减法就是加上负数, 而负数的计算方式之前有做笔记
mul
In this example, we restricted the decimal digits to 0 and 1. With only two
choices, each step of the multiplication is simple:
将十进制数转换为二进制, 根据每一位数字执行不同的选择:
- Just place a copy of the multiplicand (1 ? multiplicand) in the proper place
if the multiplier digit is a 1, or - Place 0 (0 ? multiplicand) in the proper place if the digit is 0.
Although the decimal example above happens to use only 0 and 1, multiplication
of binary numbers must always use 0 and 1, and thus always off ers only these two
choices.
1 即拷贝, 0 什么也不做
第二张图就简明多了, 简述了乘法运算的原理.
Div
就和普通的除法运算步骤是一样的