Arithmetic Operators

Summary
Arithmetic Operators
Macros
aboveGreater than comparison.
above_eqGreater than or equal comparison.
absAbsolute value.
acosArc cosine.
asinArc sine.
atanArctangent.
atan2Arctangent division.
belowLess than comparison.
below_eqLess than or equal comparison.
ceilRound up to integral value.
compareComparison.
cosCosine.
coshHyperbolic cosine.
cvt_to_objectConvert string to object.
expExponential function.
fabsFloating-point absolute value.
floorRound down to integral value.
fmodFloating-point remainder.
frexpExtract mantissa and exponent.
iscloseTest for floating point equality.
isfiniteTest for finite value.
isinfTest for infinity.
isnanTest for a NaN.
ldexpMultiply by a power of two.
logNatural logarithm.
log10Base 10 logarithm function.
modfDecompose a floating-point number.
powRaise to power.
sinSine function.
sinhHyperbolic sine function.
sqrtSquare root function.
tanTangent function.
tanhHyperbolic tangent function.
Functions
!Not operator.
!=Non-equality operator.
%Modulus operator.
%=Modulus assignment operator.
&Bitwise AND operator.
&&Logical AND operator.
&=Bitwise AND assignment operator.
*Multiplication operator.
*=Multiplication assignment operator.
+Addition operator.
++Prefix Increment.
+=Addition assignment operator.
-Subtraction operator.
--Prefix Decrement.
-=Subtraction.
/Division operator.
/=Division assignment operator.
<Less than comparison.
<<Left-shift operator.
<<=Left-shift assignment operator.
<=Less than or equal comparison.
<=>Comparison operator.
=Assignment operator.
==Equality operator.
>Greater than comparison.
>=Greater than or equal comparison.
>>Right-shift operator.
>>=Right-shift assignment operator.
^Bitwise exclusive OR operator.
^=Bitwise exclusive OR assignment operator.
post++Postfix Increment.
post--Postfix Decrement.
|Bitwise OR operator.
|=Bitwise OR assignment operator.
||Logical OR operator.
~Bitwise complement.

Macros

above

int above(declare expr1,
declare expr2)

Greater than comparison.

Description

The above() primitive is the functional form of the > operator.

The function yields the comparison of the two arguments expr1 and expr2 which both must be of equivalent types, either numeric or string; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression, numeric or string.
expr2Right expression, numeric or string.

Returns

The above() primitive yields the value 1 if expr1 is greater then expr2, and 0 if the relation is false.

Limitations

Lists can not be compared.

See Also

Operators, >

above_eq

int above_eq(declare expr1,
declare expr2)

Greater than or equal comparison.

Description

The above_eq() primitive is the functional form of the >= operator.

The function yields the comparison of the two arguments expr1 and expr2 which both must be of equivalent types, either numeric or string; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression, numeric or string.
expr2Right expression, numeric or string.

Returns

The above_eq() primitive yields the value 1 if expr1 is greater then or equals expr2, and 0 if the relation is false.

See Also

Operators, >=

abs

int abs(int val)

Absolute value.

Description

The abs() primitive computes the absolute value of an integer.

Returns

Returns the absolute value.

See Also

fabs

acos

float acos(float x)

Arc cosine.

Description

The acos() primitive shall compute the principal value of the arc cosine of the argument x.  The value of x should be in the range [-1,1].

Returns

The acos() primitive on successful completion shall return the arc cosine of xl, in the range [0,pi] radians.

Portability

Result on error are system dependent.

See Also

cos, isnan

asin

float asin(float x)

Arc sine.

Description

The asin() primitive shall compute the principal value of the arc sine of the argument x.  The value of x should be in the range [-1,1].

Returns

Upon successful completion shall return the arc sine of x, in the range [-pi/2,pi/2] radians.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

isnan, sin

atan

float atan(float x)

Arctangent.

Description

The atan() primitive calculates the arctangent of x.

Returns

Returns a value in the range -pi/2 to pi/2 radians.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

atan2

atan2

float atan2(float y,
float x)

Arctangent division.

Description

The atan2() primitive calculate the arctangent (inverse tangent) of the operand division y/x.

Returns

The atan2() primitive returns a value in the range -pi to pi radians.  If both arguments of atan2() are zero, the function sets errno to EDOM, and returns 0.  If the correct value would cause underflow, zero is returned and the value ERANGE is stored in errno.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

atan

below

int below(declare expr1,
declare expr2)

Less than comparison.

Description

The below() primitive is the functional form of the < operator.

The function yields the comparison of the two arguments expr1 and expr2 which both must be of equivalent types, either numeric or string; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression, numeric or string.
expr2Right expression, numeric or string.

Returns

The below() primitive yields the value 1 if expr1 is less than expr2, and 0 if the relation is false.

Limitations

Lists can not be compared.

See Also

Operators, <

below_eq

int below_eq(declare expr1,
declare expr2)

Less than or equal comparison.

Description

The below_eq() primitive is the functional form of the <= operator.

The function yields the comparison of the two arguments expr1 and expr2 which both must be of equivalent types, either numeric or string; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression, numeric or string.
expr2Right expression, numeric or string.

Returns

The below_eq() primitive yields the value 1 if expr1 is less then or equals expr2, and 0 if the relation is false.

Limitations

Lists can not be compared.

See Also

Operators, >=

ceil

float ceil(float x)

Round up to integral value.

Description

The ceil() primitive computes the smallest integer that is greater than or equal to x.

Returns

Returns the calculated value as a double, float, or long double value.

If there is an overflow, the function sets errno to ERANGE and returns HUGE_VAL.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

floor, fabs

compare

int compare(expr1,
expr2)

Comparison.

Description

The compare() primitive is the functional form of the <=> operator.

The function yields the comparison of the two arguments expr1 and expr2 which both must be of equivalent types, either numeric or string; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The compare() primitive yields the value -1 if the first expression is less then the second, 0 if the equals, and 1 the greater than; which are arithmetic and lexicographically comparisons respectively.

Limitations

Lists can not be compared.

See Also

Operators, declare

cos

float cos(float x)

Cosine.

Description

The cos() primitive calculates the cosine of x.  The value x is expressed in radians.

Returns

Returns the calculated value.

If x is outside prescribed limits, the value is not calculated.  Instead, the function returns 0 and sets the errno to ERANGE.

If the correct value would cause an underflow, zero is returned and the value ERANGE is stored in errno.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

sin, atan, atan2

cosh

float cosh(float x)

Hyperbolic cosine.

Description

The cosh() primitive calculates the hyperbolic cosine of x.  The value x is expressed in radians.

Returns

Returns the calculated value.

If the result overflows, the function returns +HUGE_VAL and sets errno to ERANGE.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

cos, sin

cvt_to_object

declare cvt_to_object(string value,
 [int &length])

Convert string to object.

Description

The cvt_to_object() primitive converts the initial portion of the string specified string value into an underlying int, float or string object.

Firstly, the input string is divided into three parts
  • An initial, possibly empty, sequence of white-space characters.
  • Either:
    a) A subject sequence interpreted as string of characters enclosed by either single(‘) or double(“) quotes.
    b) A subject sequence interpreted as a integer constant represented in some radix determined by the value of base.
    c) A subject sequence interpreted as a floating-point constant or representing infinity or NaN.
  • A final string of one or more unrecognised characters, including the terminating null byte of the input string.

Then they shall attempt to convert the subject sequence to either a string, integer-constant or float-point constant, and return the result.

Integer Values

If the value of base is 0, the expected form of the subject sequence is that of a decimal constant, octal constant, or hexadecimal constant, any of which may be preceded by a + or - sign.

A decimal constant begins with a non-zero digit, and consists of a sequence of decimal digits.

An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 to 7 only.

A binary constant consists of the prefix 0b or 0B followed by a sequence of the decimal digits 0 or 1.

A hexadecimal constant consists of the prefix 0x or 0X followed by a sequence of the decimal digits and letters a (or A ) to f (or F ) with values 10 to 15 respectively.

Floating Point Values

A floating-point number should have the form “SI.FESX” containing at least a fractional value or exponent, where

  • S is the sign; may be “+”, “-”, or omitted.
  • I is the integer part of the mantissa.
  • F is the fractional part of the mantissa prefixed with a dot.
  • X is the exponent.

Either I or F may be omitted, or both.  The decimal point isn’t necessary unless F is present.

A character sequence INF or INFINITY, ignoring case, shall be interpreted as an infinity; if representable.

A character sequence NAN shall be interpreted as a quiet NaN, ignoring case, shall be interpreted as an Quiet Not-A-Number; if representable.

Example

int
parsetoken(string line)
{
declare x;
int len;

x = cvt_to_object(line, len);
switch (typeof(x)) {
case "integer": // integer constant.
break;
case "float": // floating point constant.
break;
case "string": // string constant.
break;
default:
// error condition
break;
}
return len;
}

Parameters

valueString value to be parsed.
lengthOptional integer variable reference, if specified shall be populated with the number of characters consumed within the source string, including all consumed leading characters, for example white-space.  Upon a parse error the populated length shall be 0.

Returns

The cvt_to_object() primitive returns the value of the parsed object converted to the most suitable type, either as an int, float or string type.

Otherwise if the string cannot be parsed NULL is returned.

Portability

n/a

See Also

atoi, strtod

exp

float exp(float x)

Exponential function.

Description

The exp() primitive calculates the exponent of x, defined as e**x, where e equals 2.17128128....

Returns

If successful, the function returns the calculated value.

If an overflow occurs, the function returns HUGE_VAL.  If an underflow occurs, it returns 0.  Both overflow and underflow set errno to ERANGE.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

frexp, log, log10

fabs

float fabs(float x)

Floating-point absolute value.

Description

The fabs() primitive calculates the absolute value of a floating-point argument x.

Returns

Returns the absolute value of the float input.

Portability

n/a

See Also

ceil, floor, abs

floor

float floor(float x)

Round down to integral value.

Description

The floor() primitive calculates the largest integer that is less than or equal to x.

Returns

Returns the calculated integral value expressed as a double, float, or long double value.  The result cannot have a range error.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

ceil, fmod, modf, fabs

fmod

float fmod(float x,
float y)

Floating-point remainder.

Description

The fmod() primitive Calculates the floating-point remainder of x/y.  The absolute value of the result is always less than the absolute value of y.  The result will have the same sign as x.

Returns

If successful, the function returns the floating-point remainder of x/y.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

Dependent on the implementation if y is 0 one of two may occur,

  • fmod returns 0;
  • the function sets errno to EDOM and returns NaN.

No other errors will occur.

See Also

ceil, floor, modf

frexp

float frexp(float num,
int &exp)

Extract mantissa and exponent.

Description

The frexp() primitive breaks a floating-point number num into a normalised fraction and an integral power of 2.  It stores the integer exponent in the int object exp.

An application wishing to check for error situations should set errno to 0 before calling frexp().  If errno is non-zero on return, or the return value is NaN, an error has occurred.

Returns

The frexp() primitive returns the value x, such that x is a double with magnitude in the interval [0.5, 1) or 0, and num equals x times 2 raised to the power exp.

If num is 0, both parts of the result are 0.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

isnan, ldexp, modf

isclose

int isclose(float v1,
float v2,
float ~rel_tot,
float ~abs_tol)

Test for floating point equality.

Description

The isclose() primitive determines whether two floating point numbers are close in value.

Parameters

v1First string.
v2Second value to compare against.
rel_tolOptional value, used for relative tolerance.
abs_tolOptional value, used for the minimum absolute tolerance.

Returns

The isclose() primitive returns a non-zero value if v1 is close in value to v2, otherwise zero or -1 on error.

Portability

A GriefEdit extension.

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

isfinite

int isfinite(float val)

Test for finite value.

Description

The isfinite() primitive shall determine whether its argument has a finite value (zero, subnormal, or normal, and not infinite or NaN).

Returns

The isfinite() primitive shall return a non-zero value if and only if its argument has a finite value.

Portability

A GriefEdit extension.

isinf

int isinf(float val)

Test for infinity.

Description

The isinf() primitive shall determine whether its argument has a finite value (zero, subnormal, or normal, and not infinite or NaN).

Returns

The isinf() primitive shall return a non-zero value if and only if its argument has an infinite value.

Portability

A GriefEdit extension.

isnan

int isnan(float val)

Test for a NaN.

Description

The isnan() primitive tests the specified floating-point value val, returning a nonzero value if val is a not a number (NaN).

A NaN is generated when the result of a floating-point operation cannot be represented in Institute of Electrical and Electronics Engineers (IEEE) format.

On systems not supporting NaN values, isnan() always returns 0.

Returns

Non-zero if NaN, otherwise 0.

Portability

A GriefEdit extension.

ldexp

float ldexp(float val,
int exp)

Multiply by a power of two.

Description

The ldexp() primitive calculates the value of x*(2^exp).

This is x multiplied by 2 to the power of exp.

Returns

Returns the calculated value.

Otherwise, if the correct calculated value is outside the range of representable values, -/+HUGE_VAL is returned, according to the sign of the value.  The value ERANGE is stored in errno to indicate that the result was out of range.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

modf

log

float log(float x)

Natural logarithm.

Description

The log() primitive calculates the natural logarithm (base e) of x, for x greater than 0.

Returns

Returns the computed value.

If x is negative, the function sets errno to EDOM and returns -HUGE_VAL.  If x is 0.0, the function returns -HUGE_VAL and sets errno to ERANGE.

If the correct value would cause an underflow, 0 is returned and the value ERANGE is stored in errno.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

log10, exp

log10

float log10(float val)

Base 10 logarithm function.

Description

The log10() primitive calculates the base 10 logarithm of the positive value of x.

Returns

Returns the computed value.

If x is negative, the function sets errno to EDOM and returns -HUGE_VAL.  If x is 0.0, the function returns -HUGE_VAL and sets errno to ERANGE.

If the correct value would cause an underflow, 0 is returned and the value ERANGE is stored in errno.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

log, pow

modf

float modf(float num,
float &mod)

Decompose a floating-point number.

Description

The modf() primitive breaks the argument num into integral and fractional parts, each of which has the same sign as the argument.  It stores the integral part as a double in the object mod.

An application wishing to check for error situations should set errno to 0 before calling modf().  If errno is non-zero on return, or the return value is NaN, an error has occurred.

Returns

Upon successful completion, modf() returns the signed fractional part of num.

If num is NaN, NaN is returned, errno may be set to EDOM.

If the correct value would cause underflow, 0 is returned and errno may be set to ERANGE.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

frexp, isnan, ldexp

pow

float pow(float x,
float y)

Raise to power.

Description

The pow() primitive returns x raised to the power of y.

Returns

Returns the computed value.

If y is 0, the function returns 1.

If x is negative and y is non-integral, the function sets errno to EDOM and returns -HUGE_VAL.  If the correct value is outside the range of representable values, +HUGE_VAL is returned according to the sign of the value, and the value of ERANGE is stored in errno.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

exp, log

sin

float sin(float val)

Sine function.

Description

The sin() primitive computes the sine of the argument ‘val, measured in radians.

Returns

Upon successful completion, shall return the sine of x.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

asin, isnan

sinh

float sinh(float val)

Hyperbolic sine function.

Description

The sinh() primitive computes the hyperbolic sine of the argument val.

Returns

Upon successful completion, shall return the hyperbolic sine of x.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

sin

sqrt

float sqrt(float val)

Square root function.

Description

The sqrt() primitive computes the square root of the argument val.

Returns

Upon successful completion, shall return the square root of val.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

isnan

tan

float tan(float val)

Tangent function.

Description

The tan() primitive computes the tangent of the argument val, measured in radians.

Returns

Upon successful completion, shall return the tangent of val.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

atan, isnan

tanh

float tanh(float val)

Hyperbolic tangent function.

Description

The tanh() primitive computes the hyperbolic tangent of the argument val.

Returns

Upon successful completion, shall return the hyperbolic tangent of x.

Portability

Result on error are system dependent; where supported errno shall be set to a non-zero manifest constant describing the error.

See Also

tan

Functions

!

!expr

Not operator.

Description

The ! operator yields the logical not of the expression expr.

If the operand has the value zero, then the result value is 1.

If the operand has some other value, then the result is 0.

Parameters

exprExpression.

Returns

Returns the logical not of the expression expr. expr must evaluate to an integer expression.

See Also

Operators, declare

!=

expr1 != expr2

Non-equality operator.

Description

The != operator compares for inequality, yielding the value 1 if the relation is true, and 0 if the relation is false.  The result type is int.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

Limitations

Lists can not be compared.

See Also

Operators, declare

%

expr1 % expr2

Modulus operator.

Description

The % operator yields the remainder from the division of the first operand by the second operand.  The operands of must have numeric types.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

%=

var %= expr1

Modulus assignment operator.

Description

The %= operator takes the modulus of the first operand var specified by the value of the second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

&

expr1 & expr2

Bitwise AND operator.

Description

The & operator yields the result is the bitwise AND of the two operands expr1 and expr2.  That is, the bit in the result is set if and only if each of the corresponding bits in the operands are set.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

&&

expr1 && expr2

Logical AND operator.

Description

The && operator performs a logic AND between the two expressions expr1 and expr2.

Each of the operands must have scalar type.  If both of the operands are not equal to zero, then the result is 1.  Otherwise, the result is zero.  The result type is int.

Short Circuit Evaluation

Logical operators are executed using short-circuit semantics whereby the second argument is only executed or evaluated if the first argument does not suffice to determine the value of the expression:

  • Logical ADD - If the first operand is zero, then the second operand is not evaluated.  Any side effects that would have happened if the second operand had been executed do not happen.  Any function calls encountered in the second operand do not take place.
  • Logical OR - If the first operand is not zero, then the second operand is not evaluated.  Any side effects that would have happened if the second operand had been executed do not happen.  Any function calls encountered in the second operand shall not take place.

See Also

Logical Operators

&=

var &= expr1

Bitwise AND assignment operator.

Description

The &= operator obtains the bitwise AND of the first operand var and second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

*

exp1 * expr2

Multiplication operator.

Description

The * operator yields the product of its operands expr1 and expr2.  The operands must have numeric types.

Parameters

expr1Left numeric expression.
expr2Right numeric expression.

Returns

The accumulator shall be set to the result of the computation.

Notes

If either number is NaN, the result is NaN.  Multiplication of Infinity by zero gives a result of NaN, while multiplying Infinity by any non-zero number gives a result of Infinity.

See Also

Operators, declare, isnan, isfinite

*=

var *= expr1

Multiplication assignment operator.

Description

The *= operator multiplies the value of the first operand var by the value of the second operand expr1; store the result in the object specified by the first operand var.

Parameters

varAny scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

+

expr1 + expr2

Addition operator.

Description

The + operator yields the sum of its operands resulting from the addition of the first operand with the second.

If ‘expr1 or expr2 is a list, then a new list is returned which is the concatenation of expr1 and expr2.

If expr1 or expr2 is a string, then the other operand is converted to a string, and a string is returned.

If either operand is a floating point number then the other the result is the sum of the two expressions.

Otherwise the integer value of the sum of the two expressions is returned.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

A list value if either operand is a list; a string if either operand is a string; a float if either operand is a float; otherwise an integer value.

See Also

Operators, declare

++

++expr

Prefix Increment.

Description

The ++ operator increases the operand expr by 1, with the result of the operation returned.

Parameters

exprAn expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

+=

var += expr1

Addition assignment operator.

Description

The += operator adds the value of the second operand to the value of the first operand var, storing the result in the object specified by the first operand var.

Parameters

varAny scalar type.
expr1An expression resulting in value of the same type as the scalar type var.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

-

expr1 - expr2

Subtraction operator.

Description

The - operator yields the difference resulting from the subtraction of the second operand from the first.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

--

--expr

Prefix Decrement.

Description

The -- operator decreases the operand expr by 1, with the result of the operation returned.

Parameters

exprAn expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

-=

var -= expr1

Subtraction.

Description

The -= operator subtracts the value of the second operand expr1 from the value of the first operand var, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

/

expr1 / expr2

Division operator.

Description

The / operator yields the quotient from the division of the first operand by the second operand.  The operands must have numeric types.

Parameters

expr1Left numeric expression.
expr2Right numeric expression.

Returns

The accumulator shall be set to the result of the computation.

Notes

If number1 is a finite, non-zero number, and number2 is zero, the result of the division is Infinity if the number1 is positive, and -Infinity if negative.  If both number1 and number2 are zero, the result is NaN.

See Also

Operators, declare, isnan, isfinite

/=

var /= expr1

Division assignment operator.

Description

The /= operator divides the value of the first operand var by the value of the second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

<

expr1 < expr2

Less than comparison.

Description

The < operator performs less-then comparisons between the operands expr1 and expr2.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

See Also

Operators, declare

<<

expr1 << expr2

Left-shift operator.

Description

The << operator shift the value of the first operand expr1 left the number of bits specified by the value of the second operand expr1.

Both operands must have an integral type, and the integral promotions are performed on them.  The type of the result is the type of the promoted left operand.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

<<=

var <<= expr1

Left-shift assignment operator.

Description

The <<= operator shift the value of the first operand var left the number of bits specified by the value of the second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

<=

expr1 <= expr2

Less than or equal comparison.

Description

The <= operator performs less-then comparisons between the operands expr1 and expr2.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

See Also

Operators, declare

<=>

expr1 <=> expr2

Comparison operator.

Description

The <=> operator yields the value -1 if the first expression is less then the second, 0 if the equals, and 1 the greater than; which are arithmetic and lexicographically comparisons respectively.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

Limitations

Lists can not be compared.

See Also

Operators, declare

=

var = expr1

Assignment operator.

Description

The = operator applies simple assignment, in which the value of the second operand expr1 is stored in the object specified by the first operand var.

Parameters

varAny scalar type.
expr1An expression resulting in value of the same type as the scalar type var.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

==

expr1 == expr2

Equality operator.

Description

The == operator compares for equality, yielding the value 1 if the relation is true, and 0 if the relation is false.  The result type is int.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

Limitations

Lists can not be compared.

See Also

Operators, declare

>

expr1 > expr2

Greater than comparison.

Description

The > operator performs greater-then comparisons between the operands expr1 and expr2.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

See Also

Operators, declare

>=

expr1 >= expr2

Greater than or equal comparison.

Description

The > operator performs greater-then-or-equal comparisons between the operands expr1 and expr2.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the comparison.

See Also

Operators, declare

>>

expr1 >> expr2

Right-shift operator.

Description

The >> operator shift the value of the first operand expr1 right the number of bits specified by the value of the second operand expr1.

Both operands must have an integral type, and the integral promotions are performed on them.  The type of the result is the type of the promoted left operand.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

>>=

var >>= expr1

Right-shift assignment operator.

Description

The >>= operator shift the value of the first operand var right the number of bits specified by the value of the second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

^

expr1 ^ expr2

Bitwise exclusive OR operator.

Description

The ^ operator yields the result is the bitwise exclusive OR of the two operands.

That is, the bit in the result is set if and only if exactly one of the corresponding bits in the operands are set.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

^=

var ^= expr1

Bitwise exclusive OR assignment operator.

Description

The ^= operator obtains the bitwise exclusive OR of the first operand var and second operand expr1, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

post++

expr++

Postfix Increment.

Description

The post++ operator increments the operand expr by 1, with the original value prior to the operation returned.

In other words, the original value of the operand is used in the expression, and then it is incremented.

Parameters

exprAn expression.

Returns

The accumulator shall be set to orginal value of expr prior to being incremented.

See Also

Operators, declare

post--

expr--

Postfix Decrement.

Description

The post-- operator decrements the operand expr by 1, with the original value prior to the operation returned.

In other words, the original value of the operand is used in the expression, and then it is decremented.

Parameters

exprAn expression.

Returns

The accumulator shall be set to orginal value of expr prior to being decremented.

See Also

Operators, declare

|

expr1 | expr2

Bitwise OR operator.

Description

The | operator yields the result is the bitwise inclusive OR of the two operands expr1 and expr2.  That is, the bit in the result is set if at least one of the corresponding bits in the operands is set.

Parameters

expr1Left expression.
expr2Right expression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

|=

var |= expr1

Bitwise OR assignment operator.

Description

The |= operator obtains the bitwise inclusive OR of the first operand var and second operand var, storing the result in the object specified by the first operand var.

Parameters

varA numeric scalar type.
expr1A numeric expression.

Returns

The accumulator shall be set to the result of the assignment.

See Also

Operators, declare

||

expr1 || expr2

Logical OR operator.

Description

The || operator performs a logic OR between the two expressions expr1 and expr2.

Each of the operands must have scalar type.  If one or both of the operands is not equal to zero, then the result is 1.  Otherwise, the result is zero (both operands are zero).  The result type is int.

Short Circuit Evaluation

Logical operators are executed using short-circuit semantics whereby the second argument is only executed or evaluated if the first argument does not suffice to determine the value of the expression:

  • Logical ADD - If the first operand is zero, then the second operand is not evaluated.  Any side effects that would have happened if the second operand had been executed do not happen.  Any function calls encountered in the second operand do not take place.
  • Logical OR - If the first operand is not zero, then the second operand is not evaluated.  Any side effects that would have happened if the second operand had been executed do not happen.  Any function calls encountered in the second operand shall not take place.

See Also

Logical Operators

~

~expr

Bitwise complement.

Description

The ^ operator yields the bitwise complement 1’s complement or bitwise not operator of expr.

The type of the operand must be an integral type, and integral promotion is performed on the operand.  The type of the result is the type of the promoted operand.

Each bit of the result is the complement of the corresponding bit in the operand, effectively turning 0 bits to 1, and 1 bits to 0.  The ! symbol is the logical not operator.  Its operand must be a scalar type (not a structure, union or array).  The result type is int.

If the operand has the value zero, then the result value is 1.

If the operand has some other value, then the result is 0.

Parameters

exprExpression.

Returns

The accumulator shall be set to the result of the computation.

See Also

Operators, declare

$Id: $

To send feedback on this topic email: grie.nosp@m.fedit@gmai.nosp@m.l.com

Copyright © Adam Young All Rights Reserved.

int above(declare expr1,
declare expr2)
Greater than comparison.
int above_eq(declare expr1,
declare expr2)
Greater than or equal comparison.
int abs(int val)
Absolute value.
float acos(float x)
Arc cosine.
float asin(float x)
Arc sine.
float atan(float x)
Arctangent.
float atan2(float y,
float x)
Arctangent division.
int below(declare expr1,
declare expr2)
Less than comparison.
int below_eq(declare expr1,
declare expr2)
Less than or equal comparison.
float ceil(float x)
Round up to integral value.
int compare(expr1,
expr2)
Comparison.
float cos(float x)
Cosine.
float cosh(float x)
Hyperbolic cosine.
declare cvt_to_object(string value,
 [int &length])
Convert string to object.
float exp(float x)
Exponential function.
float fabs(float x)
Floating-point absolute value.
float floor(float x)
Round down to integral value.
float fmod(float x,
float y)
Floating-point remainder.
float frexp(float num,
int &exp)
Extract mantissa and exponent.
int isclose(float v1,
float v2,
float ~rel_tot,
float ~abs_tol)
Test for floating point equality.
int isfinite(float val)
Test for finite value.
int isinf(float val)
Test for infinity.
int isnan(float val)
Test for a NaN.
float ldexp(float val,
int exp)
Multiply by a power of two.
float log(float x)
Natural logarithm.
float log10(float val)
Base 10 logarithm function.
float modf(float num,
float &mod)
Decompose a floating-point number.
float pow(float x,
float y)
Raise to power.
float sin(float val)
Sine function.
float sinh(float val)
Hyperbolic sine function.
float sqrt(float val)
Square root function.
float tan(float val)
Tangent function.
float tanh(float val)
Hyperbolic tangent function.
!expr
Not operator.
expr1 != expr2
Non-equality operator.
expr1 % expr2
Modulus operator.
var %= expr1
Modulus assignment operator.
expr1 & expr2
Bitwise AND operator.
expr1 && expr2
Logical AND operator.
var &= expr1
Bitwise AND assignment operator.
exp1 * expr2
Multiplication operator.
var *= expr1
Multiplication assignment operator.
expr1 + expr2
Addition operator.
++expr
Prefix Increment.
var += expr1
Addition assignment operator.
expr1 - expr2
Subtraction operator.
--expr
Prefix Decrement.
var -= expr1
Subtraction.
expr1 / expr2
Division operator.
var /= expr1
Division assignment operator.
expr1 < expr2
Less than comparison.
expr1 << expr2
Left-shift operator.
var <<= expr1
Left-shift assignment operator.
expr1 <= expr2
Less than or equal comparison.
expr1 <=> expr2
Comparison operator.
var = expr1
Assignment operator.
expr1 == expr2
Equality operator.
expr1 > expr2
Greater than comparison.
expr1 >= expr2
Greater than or equal comparison.
expr1 >> expr2
Right-shift operator.
var >>= expr1
Right-shift assignment operator.
expr1 ^ expr2
Bitwise exclusive OR operator.
var ^= expr1
Bitwise exclusive OR assignment operator.
expr++
Postfix Increment.
expr--
Postfix Decrement.
expr1 | expr2
Bitwise OR operator.
var |= expr1
Bitwise OR assignment operator.
expr1 || expr2
Logical OR operator.
~expr
Bitwise complement.
An operator is used to describe an operation applied to one or several objects.
declare sym1, sym2 ...;
Declare a polymorphic symbol.
int sym1, sym2 ...;
Declare an integer symbol.
float sym1, sym2 ...;
Declare a float symbol.
string sym1, sym2 ...;
Declare a string symbol.
int atoi(string str,
 [int svalue = TRUE])
Convert string to a decimal number.
int strtod(string str,
 [int &endofoffset])
String to double.
Logical operations are executed by the following operators