附录 B(规范性)Type 4 函数中的操作符¶
Annex B (normative) Operators in Type 4 Functions
B.1 概述¶
B.1 General
本附件总结了可能出现在类型 4 函数中的 PostScript 运算符,如 7.10.5“类型 4(PostScript 计算器)函数”中所述。有关这些运算符的详细信息,请参阅《PostScript 语言参考》第三版。
This annex summarizes the PostScript operators that may appear in a type 4 function, as discussed in 7.10.5, "Type 4 (PostScript Calculator) Functions". For details on these operators, see the PostScript Language Reference, Third Edition.
B.2 算术操作符¶
B.2 Arithmetic Operators
\(\text{num}_1 \space \text{num}_2\) | add sum | 返回 \(\text{num}_1\) 加 \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | sub difference | 返回 \(\text{num}_1\) 减 \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | mul product | 返回 \(\text{num}_1\) 乘以 \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | div 商 | 返回 \(\text{num}_1\) 除以 \(\text{num}_2\) |
\(\text{int}_1 \space \text{int}_2\) | idiv 商 | 返回 int1 除以 int2 后的整数 |
\(\text{int}_1 \space \text{int}_2\) | mod 余数 | 返回 int1 除以 int2 后的余数 |
\(\text{num}_1\) | neg \(\text{num}_2\) | 返回\(\text{num}_1\) 的负数 |
\(\text{num}_1\) | abs \(\text{num}_2\) | 返回 \(\text{num}_1\) 的绝对值 |
\(\text{num}_1\) | ceiling \(\text{num}_2\) | 返回 \(\text{num}_1\) 的上限 |
\(\text{num}_1\) | floor \(\text{num}_2\) | 返回 \(\text{num}_1\) 的下限 |
\(\text{num}_1\) | round \(\text{num}_2\) | 将 \(\text{num}_1\) 返回为最接近的整数 |
\(\text{num}_1\) | truncate \(\text{num}_2\) | 删除 \(\text{num}_1\) 的小数部分 |
\(\text{num}\) | sqrt \(\text{num}_2\) | 返回 num 的平方根 |
num | sqrt real | 返回 num 的平方根 |
angle | sin real | 返回角度的正弦度 |
角度 | cos real | 返回角度的余弦度 |
num den | atan angle | 返回 num/den 的反正切度 |
base exponent | exp real | 将底数提升为指数幂 |
num | ln real | 返回自然对数(底数为 e) |
num | log real | 返回常用对数(底数为10) |
num | cvi int | 转换为整数 |
num | cvr real | 转换为实数 |
\(\text{num}_1 \space \text{num}_2\) | add sum | Return \(\text{num}_1\) plus \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | sub difference | Return \(\text{num}_1\) minus \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | mul product | Return \(\text{num}_1\) times \(\text{num}_2\) |
\(\text{num}_1 \space \text{num}_2\) | div quotient | Return \(\text{num}_1\) divided by \(\text{num}_2\) |
\(\text{int}_1 \space \text{int}_2\) | idiv quotient | Return int1 divided by int2 as an integer |
\(\text{int}_1 \space \text{int}_2\) | mod remainder | Return remainder after dividing int1 by int2 |
\(\text{num}_1\) | neg \(\text{num}_2\) | Return negative of \(\text{num}_1\) |
\(\text{num}_1\) | abs \(\text{num}_2\) | Return absolute of \(\text{num}_1\) |
\(\text{num}_1\) | ceiling \(\text{num}_2\) | Return ceiling of \(\text{num}_1\) |
\(\text{num}_1\) | floor \(\text{num}_2\) | Return floor of \(\text{num}_1\) |
\(\text{num}_1\) | round \(\text{num}_2\) | Return \(\text{num}_1\) to nearest integer |
\(\text{num}_1\) | truncate \(\text{num}_2\) | Remove fractional part of \(\text{num}_1\) |
\(\text{num}\) | sqrt \(\text{num}_2\) | Return square root of num |
num | sqrt real | Return square root of num |
angle | sin real | Return sine of angle degrees |
angle | cos real | Return cosine of angle degrees |
num den | atan angle | Return arc tangent of num/den in degrees |
base exponent | exp real | Raise base to exponent power |
num | ln real | Return natural logarithm (base e) |
num | log real | Return common logarithm (base 10) |
num | cvi int | Convert to integer |
num | cvr real | Convert to real |
B.3 关系、布尔和位操作符¶
B.3 Relational, Boolean, and Bitwise Operators
\(\text{any}_1 \space \text{any}_2\) | eq bool | 测试相等 |
\(\text{any}_1 \space \text{any}_2\) | ne bool | 测试不相等 |
\(\text{num}_1 \space \text{num}_2\) | gt bool | 测试大于 |
\(\text{num}_1 \space \text{num}_2\) | ge bool | 测试大于或相等 |
\(\text{num}_1 \space \text{num}_2\) | lt bool | 测试小于 |
\(\text{num}_1 \space \text{num}_2\) | le bool | 测试小于或等于 |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | and \(\text{bool}_3 | \text{int}_3\) | 执行逻辑 | 按位与 |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | 或 \(\text{bool}_3 | \text{int}_3\) | 执行逻辑 | 按位包含或 |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | xor \(\text{bool}_3 | \text{int}_3\) | 执行逻辑 | 按位排他或 |
\(\text{bool}_1 \space | int_1\) | 非 \(\text{bool}_2 | \text{int}_2\) | 执行逻辑 | 按位非 |
\(\text{int}_1 shift\) | bitshift \(\text{int}_2\) | 执行 \(\text{int}_1\) 的按位移位(正数为左移) |
– | true true | 返回布尔值 true |
– | false false | 返回布尔值 false |
\(\text{any}_1 \space \text{any}_2\) | eq bool | Test equal |
\(\text{any}_1 \space \text{any}_2\) | ne bool | Test not equal |
\(\text{num}_1 \space \text{num}_2\) | gt bool | Test greater than |
\(\text{num}_1 \space \text{num}_2\) | ge bool | Test greater than or equal |
\(\text{num}_1 \space \text{num}_2\) | lt bool | Test less than |
\(\text{num}_1 \space \text{num}_2\) | le bool | Test less than or equal |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | and \(\text{bool}_3 | \text{int}_3\) | Perform logical | bitwise and |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | or \(\text{bool}_3 | \text{int}_3\) | Perform logical | bitwise inclusive or |
\(\text{bool}_1 \space | \space int_1 \space bool_2 \space | \space \text{int}_2\) | xor \(\text{bool}_3 | \text{int}_3\) | Perform logical | bitwise exclusive or |
\(\text{bool}_1 \space | int_1\) | not \(\text{bool}_2 | \text{int}_2\) | Perform logical | bitwise not |
\(\text{int}_1 shift\) | bitshift \(\text{int}_2\) | Perform bitwise shift of \(\text{int}_1\) (positive is left) |
– | true true | Return boolean value true |
– | false false | Return boolean value false |
B.4 条件操作符¶
B.4 Conditional Operators
bool { expr } | if – | 如果 bool 为 true,则执行 expr |
bool { \(\text{expr}_1\) } { \(\text{expr}_2\) } | ifelse – | 如果 bool 为 true,则执行 expr1,如果为 false,则执行 expr2 |
bool { expr } | if – | Execute expr if bool is true |
bool { \(\text{expr}_1\) } { \(\text{expr}_2\) } | ifelse – | Execute expr1 if bool is true, expr2 if false |
B.5 栈操作符¶
B.5 Stack Operators
any | pop – | 丢弃顶部元素 |
\(\text{any}_1 \space \text{any}_2\) | exch \(\text{any}_2 any_1\) | 交换顶部两个元素 |
any | dup any any | 复制顶部元素 |
\(\text{any}_1 \space … \space any_n \space n\) | copy \(\text{any}_1 … any_n any_1 … any_n\) | 复制顶部 n元素 |
\(\text{any}_n \space … \space any_0 \space n\) | index \(\text{any}_n … any_0 any_n\) | 重复任意元素 |
\(\text{any}_{n-1} \space … \space any_0 \space n \space j\) | roll \(\text{any}_{(j-1) \space mod \space n} \space … \space any_0 \space any_{n-1} \space … \space any_{j \space mod \space n}\) | cccc |
any | pop – | Discard top element |
\(\text{any}_1 \space \text{any}_2\) | exch \(\text{any}_2 any_1\) | Exchange top two elements |
any | dup any any | Duplicate top element |
\(\text{any}_1 \space … \space any_n \space n\) | copy \(\text{any}_1 … any_n any_1 … any_n\) | Duplicate top n elements |
\(\text{any}_n \space … \space any_0 \space n\) | index \(\text{any}_n … any_0 any_n\) | Duplicate arbitrary element |
\(\text{any}_{n-1} \space … \space any_0 \space n \space j\) | roll \(\text{any}_{(j-1) \space mod \space n} \space … \space any_0 \space any_{n-1} \space … \space any_{j \space mod \space n}\) | cccc |