GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfPostScriptCalculatorOperator Enum

    Namespace:
    GemBox.Pdf.Functions
    Assembly:
    GemBox.Pdf.dll

    Represents a PostScript operator that may appear in a PdfPostScriptCalculatorFunction.

    • C#
    • VB.NET
    public enum PdfPostScriptCalculatorOperator
    Public Enum PdfPostScriptCalculatorOperator

    Fields

    abs

    num1 abs num2

    returns the absolute value of num1. The type of the result is the same as the type of num1 unless num1 is the smallest (most negative) integer, in which case the result is a real number.

    Examples

    4.5 abs ⇒ 4.5
    -3 abs ⇒ 3
    0 abs ⇒ 0

    Errors: stackunderflow, typecheck

    See Also: neg

    add

    num1 num2 add sum

    returns the sum of num1 and num2. If both operands are integers and the result is within integer range, the result is an integer; otherwise, the result is a real number.

    Examples

    3 4 add ⇒ 7
    9.9 1.1 add ⇒ 11.0

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: div, mul, sub, idiv, mod

    and

    bool1 bool2 and bool3

    int1 int2 and int3

    returns the logical conjunction of the operands if they are boolean. If the operands are integers, and returns the bitwise "and" of their binary representations.

    Examples

    true true and ⇒ true % A complete truth table
    true false and ⇒ false
    false true and ⇒ false
    false false and ⇒ false
    99 1 and ⇒ 1
    52 7 and ⇒ 4

    Errors: stackunderflow, typecheck

    See Also: or, xor, not, true, false

    atan

    num den atan angle

    returns the angle (in degrees between 0 and 360) whose tangent is num divided by den. Either num or den may be 0, but not both. The signs of num and den determine the quadrant in which the result will lie: a positive num yields a result in the positive y plane, while a positive den yields a result in the positive x plane. The result is a real number.

    Examples

    0 1 atan ⇒ 0.0
    1 0 atan ⇒ 90.0
    -100 0 atan ⇒ 270.0
    4 4 atan ⇒ 45.0

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: cos, sin

    bitshift

    int1 shift bitshift int2

    shifts the binary representation of int1 left by shift bits and returns the result. Bits shifted out are lost; bits shifted in are 0. If shift is negative, a right shift by –shift bits is performed. This operation produces an arithmetically correct result only for positive values of int1. Both int1 and shift must be integers.

    Examples

    7 3 bitshift ⇒ 56
    142 –3 bitshift ⇒ 17

    Errors: stackunderflow, typecheck

    See Also: and, or, xor, not

    ceiling

    num1 ceiling num2

    returns the least integer value greater than or equal to num1. The type of the result is the same as the type of the operand.

    Examples

    3.2 ceiling ⇒ 4.0
    –4.8 ceiling ⇒ –4.0
    99 ceiling ⇒ 99

    Errors: stackunderflow, typecheck

    See Also: floor, round, truncate, cvi

    copy

    any1 … anyn n copy any1 … anyn any1 … anyn

    pops n from the stack and duplicates the top n elements on the stack as shown above.

    Examples

    5 4 3 2 copy ⇒ 5 4 3 4 3
    5 4 3 0 copy ⇒ 5 4 3

    Errors: rangecheck, stackoverflow, stackunderflow, typecheck

    See Also: dup

    cos

    angle cos real

    returns the cosine of angle, which is interpreted as an angle in degrees. The result is a real number.

    Examples

    0 cos ⇒ 1.0
    90 cos ⇒ 0.0

    Errors: stackunderflow, typecheck

    See Also: atan, sin

    cvi

    num cvi int

    (convert to integer) takes an integer or real number from the stack and produces an integer result. If the operand is an integer, cvi simply returns it. If the operand is a real number, it truncates any fractional part (that is, rounds it toward 0) and converts it to an integer. A rangecheck error occurs if a real number is too large to convert to an integer. (See the round, truncate, floor, and ceiling operators, which remove fractional parts without performing type conversion.)

    Examples

    –47.8 cvi ⇒ –47
    520.9 cvi ⇒ 520

    Errors: rangecheck, stackunderflow, typecheck

    See Also: cvr, ceiling, floor, round, truncate

    cvr

    num cvr real

    (convert to real) takes an integer or real number and produces a real result. If the operand is an integer, cvr converts it to a real number. If the operand is a real number, cvr simply returns it.

    Errors: stackunderflow, typecheck

    See Also: cvi

    div

    num1 num2 div quotient

    divides num1 by num2, producing a result that is always a real number even if both operands are integers. Use idiv instead if the operands are integers and an integer result is desired.

    Examples

    3 2 div ⇒ 1.5
    4 2 div ⇒ 2.0

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: idiv, add, mul, sub, mod

    dup

    any dup any any

    duplicates the top element on the operand stack.

    Errors: stackoverflow, stackunderflow

    See Also: copy, index

    eq

    any1 any2 eq bool

    pops two objects from the operand stack and pushes true if they are equal, or false if not. The definition of equality depends on the types of the objects being compared. Simple objects are equal if their types and values are the same.

    This operator performs some type conversions. Integers and real numbers can be compared freely: an integer and a real number representing the same mathematical value are considered equal by eq.

    Examples

    4.0 4 eq ⇒ true % A real number and an integer may be equal

    Errors: stackunderflow

    See Also: ne, le, lt, ge, gt

    exch

    any1 any2 exch any2 any1

    exchanges the top two elements on the operand stack.

    Examples

    1 2 exch ⇒ 2 1

    Errors: stackunderflow

    See Also: dup, roll, index, pop

    exp

    base exponent exp real

    raises base to the exponent power. The operands may be either integers or real numbers. If the exponent has a fractional part, the result is meaningful only if the base is nonnegative. The result is always a real number.

    Examples

    9 0.5 exp ⇒ 3.0
    -9 -1 exp ⇒ -0.111111

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: sqrt, ln, log, mul

    Expression

    Push the expression on the stack.

    Errors: stackoverflow

    false

    – false false

    pushes a boolean object whose value is false on the operand stack.

    Errors: stackoverflow

    See Also: true, and, or, not, xor

    floor

    num1 floor num2

    returns the greatest integer value less than or equal to num1. The type of the result is the same as the type of the operand.

    Examples

    3.2 floor ⇒ 3.0
    –4.8 floor ⇒ –5.0
    99 floor ⇒ 99

    Errors: stackunderflow, typecheck

    See Also: ceiling, round, truncate, cvi

    ge

    num1 num2 ge bool

    pops two numbers from the operand stack and pushes true if the first number is greater than or equal to the second, or false otherwise.

    Examples

    4.2 4 ge ⇒ true

    Errors: stackunderflow, typecheck

    See Also: gt, eq, ne, le, lt

    gt

    num1 num2 gt bool

    pops two numbers from the operand stack and pushes true if the first number is greater than the second, or false otherwise.

    Errors: stackunderflow, typecheck

    See Also: ge, eq, ne, le, lt

    idiv

    int1 int2 idiv quotient

    divides int1 by int2 and returns the integer part of the quotient, with any fractional part discarded. Both operands of idiv must be integers and the result is an integer.

    Examples

    3 2 idiv ⇒ 1
    4 2 idiv ⇒ 2
    -5 2 idiv ⇒ -2

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: div, add, mul, sub, mod, cvi

    if

    bool {expr} if -

    removes both operands from the stack, then executes {expr} if bool is true. The if operator pushes no results of its own on the operand stack, but {expr} may do so.

    Examples

    3 4 lt {3 4 add} if ⇒ 7

    Errors: stackunderflow, typecheck

    See Also: ifelse

    ifelse

    bool {expr1} {expr2} ifelse -

    removes all three operands from the stack, then executes {expr1} if bool is true or {expr2} if bool is false. The ifelse operator pushes no results of its own on the operand stack, but the expression it executes may do so.

    Examples

    4 3 lt {4 3 add} {4 3 sub} ifelse ⇒ 1 % Since 4 is not less than 3

    Errors: stackunderflow, typecheck

    See Also: if

    index

    anyn … any0 n index anyn … any0 anyn

    removes the nonnegative integer n from the operand stack, counts down to the nth element from the top of the stack, and pushes a copy of that element on the stack.

    Examples

    7 6 5 4 0 index ⇒ 7 6 5 4 4
    7 6 5 4 3 index ⇒ 7 6 5 4 7

    Errors: rangecheck, stackunderflow, typecheck

    See Also: copy, dup, roll

    le

    num1 num2 le bool

    pops two numbers from the operand stack and pushes true if the first number is less than or equal to the second, or false otherwise.

    Errors: stackunderflow, typecheck

    See Also: lt, eq, ne, ge, gt

    ln

    num ln real

    returns the natural logarithm (base e) of num. The result is a real number.

    Examples

    10 ln ⇒ 2.30259
    100 ln ⇒ 4.60517

    Errors: rangecheck, stackunderflow, typecheck

    See Also: log, exp

    log

    num log real

    returns the common logarithm (base 10) of num. The result is a real number.

    Examples

    10 log ⇒ 1.0
    100 log ⇒ 2.0

    Errors: rangecheck, stackunderflow, typecheck

    See Also: ln, exp

    lt

    num1 num2 lt bool

    pops two numbers from the operand stack and pushes true if the first number is less than the second, or false otherwise.

    Errors: stackunderflow, typecheck

    See Also: le, eq, ne, ge, gt

    mod

    int1 int2 mod remainder

    returns the remainder that results from dividing int1 by int2. The sign of the result is the same as the sign of the dividend int1. Both operands must be integers and the result is an integer.

    Examples

    5 3 mod ⇒ 2
    5 2 mod ⇒ 1
    -5 3 mod ⇒ -2

    The last example above demonstrates that mod is a remainder operation rather than a true modulo operation.

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: idiv, div

    mul

    num1 num2 mul product

    returns the product of num1 and num2. If both operands are integers and the result is within integer range, the result is an integer; otherwise, the result is a real number.

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: div, idiv, add, sub, mod

    ne

    any1 any2 ne bool

    pops two objects from the operand stack and pushes false if they are equal, or true if not. What it means for objects to be equal is presented in the description of the eq operator.

    Errors: stackunderflow

    See Also: eq, ge, gt, le, lt

    neg

    num1 neg num2

    returns the negative of num1. The type of the result is the same as the type of num1 unless num1 is the smallest (most negative) integer, in which case the result is a real number.

    Examples

    4.5 neg ⇒ -4.5
    -3 neg ⇒ 3

    Errors: stackunderflow, typecheck

    See Also: abs

    not

    bool1 not bool2

    int1 not int2

    returns the logical negation of the operand if it is boolean. If the operand is an integer, not returns the bitwise complement (ones complement) of its binary representation.

    Examples

    true not ⇒ false % A complete truth table
    false not ⇒ true
    52 not ⇒ -53

    Errors: stackunderflow, typecheck

    See Also: and, or, xor, if

    Number

    Push the number (System.Int32 or System.Double) constant on the stack.

    Errors: stackoverflow

    or

    bool1 bool2 or bool3

    int1 int2 or int3

    returns the logical disjunction of the operands if they are boolean. If the operands are integers, or returns the bitwise "inclusive or" of their binary representations.

    Examples

    true true or ⇒ true % A complete truth table
    true false or ⇒ true
    false true or ⇒ true
    false false or ⇒ false
    17 5 or ⇒ 21

    Errors: stackunderflow, typecheck

    See Also: and, not, xor

    pop

    any pop -

    removes the top element from the operand stack and discards it.

    Examples

    1 2 3 pop ⇒ 1 2
    1 2 3 pop pop ⇒ 1

    Errors: stackunderflow

    See Also: dup

    roll

    anyn-1 … any0 n j roll any(j-1) mod n … any0 anyn-1 … anyj mod n

    performs a circular shift of the objects anyn-1 through any0 on the operand stack by the amount j. Positive j indicates upward motion on the stack, whereas negative j indicates downward motion.

    n must be a nonnegative integer and j must be an integer. roll first removes these operands from the stack; there must be at least n additional elements. It then performs a circular shift of these n elements by j positions.

    If j is positive, each shift consists of removing an element from the top of the stack and inserting it between element n - 1 and element n of the stack, moving all intervening elements one level higher on the stack. If j is negative, each shift consists of removing element n - 1 of the stack and pushing it on the top of the stack, moving all intervening elements one level lower on the stack.

    Examples

    6 5 4 3 -1 roll ⇒ 5 4 6
    6 5 4 3 1 roll ⇒ 4 6 5
    6 5 4 3 0 roll ⇒ 6 5 4

    Errors: rangecheck, stackunderflow, typecheck

    See Also: exch, index, copy, pop

    round

    num1 round num2

    returns the integer value nearest to num1. If num1 is equally close to its two nearest integers, round returns the greater of the two. The type of the result is the same as the type of the operand.

    Examples

    3.2 round ⇒ 3.0
    6.5 round ⇒ 7.0
    -4.8 round ⇒ -5.0
    -6.5 round ⇒ -6.0
    99 round ⇒ 99

    Errors: stackunderflow, typecheck

    See Also: ceiling, floor, truncate, cvi

    sin

    angle sin real

    returns the sine of angle, which is interpreted as an angle in degrees. The result is a real number.

    Errors: stackunderflow, typecheck

    See Also: cos, atan

    sqrt

    num sqrt real

    returns the square root of num, which must be a nonnegative number. The result is a real number.

    Errors: rangecheck, stackunderflow, typecheck

    See Also: exp

    sub

    num1 num2 sub difference

    returns the result of subtracting num2 from num1. If both operands are integers and the result is within integer range, the result is an integer; otherwise, the result is a real number.

    Errors: stackunderflow, typecheck, undefinedresult

    See Also: add, div, mul, idiv, mod

    true

    – true true

    pushes a boolean object whose value is true on the operand stack.

    Errors: stackoverflow

    See Also: false, and, or, not, xor

    truncate

    num1 truncate num2

    truncates num1 toward 0 by removing its fractional part. The type of the result is the same as the type of the operand.

    Examples

    3.2 truncate ⇒ 3.0
    -4.8 truncate ⇒ -4.0
    99 truncate ⇒ 99

    Errors: stackunderflow, typecheck

    See Also: ceiling, floor, round, cvi

    Unknown

    The PostScript Calculator operator is unknown and not supported.

    Errors: unregistered

    xor

    bool1 bool2 xor bool3

    int1 int2 xor int3

    returns the logical "exclusive or" of the operands if they are boolean. If the operands are integers, xor returns the bitwise "exclusive or" of their binary representations.

    Examples

    true true xor ⇒ false % A complete truth table
    true false xor ⇒ true
    false true xor ⇒ true
    false false xor ⇒ false
    7 3 xor ⇒ 4
    12 3 xor ⇒ 15

    Errors: stackunderflow, typecheck

    See Also: or, and, not

    See Also
    PDF Specification ISO 32000-1:2008, section '7.10.5 Type 4 (PostScript Calculator) Functions'
    PDF Specification ISO 32000-1:2008, section 'Annex B (normative) Operators in Type 4 Functions'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.