Arithmetic combinator/zh: Difference between revisions
		
		
		
		Jump to navigation
		Jump to search
		
m →请参见:  fixed links  | 
				 I understand the motivation, however there is no double space there on any page, so this should be uniform. Instead, I increased the top padding of the navbox to better separate it from the content.  | 
				||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{Languages}}  | {{Languages}}{{:Infobox:Arithmetic combinator}}  | ||
{{:Infobox:Arithmetic combinator}}  | |||
'''{{Translation|Arithmetic combinator}}'''是游戏里构成{{L|Circuit network}}三个运算器的其中之一(另外两个是{{L|Constant combinator}}和{{L|Decider combinator}})。每个{{Translation|Arithmetic combinator}}在接收到信号后都可以执行以下的一种运算,并会在上面显示对应的操作符符号。  | '''{{Translation|Arithmetic combinator}}'''是游戏里构成{{L|Circuit network}}三个运算器的其中之一(另外两个是{{L|Constant combinator}}和{{L|Decider combinator}})。每个{{Translation|Arithmetic combinator}}在接收到信号后都可以执行以下的一种运算,并会在上面显示对应的操作符符号。  | ||
| Line 60: | Line 59: | ||
* [[Tutorial:Combinator tutorial/zh|运算器教程]]  | * [[Tutorial:Combinator tutorial/zh|运算器教程]]  | ||
* [[Tutorial:Circuit network cookbook/zh|{{Translation|Circuit network}}示例大全]]  | * [[Tutorial:Circuit network cookbook/zh|{{Translation|Circuit network}}示例大全]]  | ||
{{LogisticsNav}}  | {{LogisticsNav}}  | ||
{{C|Circuit network}}  | {{C|Circuit network}}  | ||
Latest revision as of 07:54, 10 July 2018
| 算术运算器 | 
| 
 生产配方  | 
|||||||||||||
| ++ → | |||||||||||||
| 
 原料总计  | 
|||||||||||||
| ++ | |||||||||||||
| 
 地图标识颜色  | 
|||||||||||||
| 
 生命值  | 
  | 
||||||||||||
| 
 堆叠数量  | 
 50  | 
||||||||||||
| 
 50 (1 组)  | 
|||||||||||||
| 
 能量消耗  | 
 1 kw (电能)  | 
||||||||||||
| 
 开采工时  | 
 0.1  | 
||||||||||||
| 
 原型类型  | 
|||||||||||||
| 
 内部名称  | 
 arithmetic-combinator  | 
||||||||||||
| 
 前置科技  | 
|||||||||||||
| 
 可由以下设施生产  | 
|||||||||||||
算术运算器是游戏里构成信号网络三个运算器的其中之一(另外两个是常量运算器和判断运算器)。每个算术运算器在接收到信号后都可以执行以下的一种运算,并会在上面显示对应的操作符符号。
- 加法(+)
 - 减法(-)
 - 乘法(*)
 - 除法(/)
 - 取余数(%)
 - 幂(^)
 - 左移位(<<)
 - 右移位(>>)
 - 按位与(&)
 - 按位或(|)
 - 按位异或(^)
 
算术运算器接受两路输入(红线缆和绿线缆),并将结果发送到两路输出口。以右侧信息栏上的图片为准,输入口是左侧的两个端点,输出口位于右侧。
功能说明
算术运算器内部的处理逻辑分为三步:
- 所有的输入口的值在运算器内部会被相加。
 - 指定的操作符会在所设置的信号上执行。
 - 运算的结果会被以指定的信号输出。
 
左侧的操作数(简称左值)可以是任意的信号或者是“每个”虚拟信号,右侧的操作数(简称右值)可以是任意的信号或者是一个常量值。
如果左值是“每个”信号,那么输出值既可以是单个信号,也可以是“每个”信号。如果输出信号是“每个”信号,那么输入信号上的值会分别与右值计算,并以同样的信号进行输出。如果输出信号是单一信号,那么输入信号上的所有值在与右值计算后,会被相加,并将相加结果以指定的信号输出。
运算时要注意的点
当使用除法时,结果的小数部分会被忽略:
- 21 / 10 = 2
 - 19 / 10 = 1
 - -21 / 10 = -2
 - -19 / 10 = -1
 - 21 / -10 = -2
 - 19 / -10 = -1
 - -21 / -10 = 2
 - -19 / -10 = 1
 
取余数运算符在大部分编程语言中都是以%来表示,代表取除法除不开的那部分的值。举例,13 % 3 等于 1(13 = 4 * 3 + 1)。这种运算与除法相配合可以用来获取一个数字中指定位置的数字:
- (24321 / 10000) % 10 = 2
 - (24321 / 1000) % 10 = 4
 - (24321 / 100) % 10 = 3
 - (24321 / 10) % 10 = 2
 - (24321 / 1) % 10 = 1
 
取余中,对左值进行取反操作会得到取反的结果,但是对右值取反则没有任何作用:
- 13 % 3 = 1
 - 13 % -3 = 1
 - -13 % 3 = -1
 - -13 % -3 = -1
 
右移位是算术移位(依正负值扩展),而逻辑移位。
