Apama Documentation : Developing Apama Applications : EPL Reference : Types : Primitive and string types : integer
integer
Values of the integer type are negative, zero, and positive integers encoded as 64-bit signed two's complement binary integers. The lowest negative value that can be stored in a variable of type integer is -9223372036854775808 (or -263) and the highest positive value that can be stored is 9223372036854775807 (or 263 - 1).
There are a few integer constants provided in EPL. See Support for IEEE 754 special values.
Operators
The following table describes the EPL operators available for use with integer values.
Operator
Description
Result Type
<
Less-than comparison
boolean
<=
Less-than or equal comparison
boolean
=
Equal comparison
boolean
!=
Not equal comparison
boolean
>=
Greater-than or equal comparison
boolean
>
Greater-than comparison
boolean
+
Unary integral identity
integer
-
Unary integral additive inverse
integer
+
Integral addition
integer
-
Integral subtraction
integer
*
Integral multiplication
integer
/
Integral division
integer
%
Integral remainder
integer
or
Bitwise or
integer
and
Bitwise and
integer
xor
Bitwise exclusive or
integer
not
Unary bitwise inverse
integer
>>
Bitwise shift right
integer
<<
Bitwise shift left
integer
An attempt to divide by zero (0) or to compute a remainder of zero raises an error. Overflows and underflows in arithmetic are ignored by the EPL runtime.
When you use the shift operators, the sign of a result value can differ from that of the operand value being shifted. When you use not the sign of the result value will be the opposite of that of its operand.
Methods
The following methods may be called on variables of integer type:
*abs()Returns as an integer the absolute value of i or |i|, where i is the value of the integer.
*canParse()Returns true if the string argument can be successfully parsed.
*getUnique()Generates a unique integer in the scope of the correlator. This is a type method as well as an instance method. It returns an integer that is unique for the correlator session's lifetime. When the correlator is shut down and restarted, then the integers returned might be the same as some or all of the values produced in the earlier session.
When correlator persistence is enabled the state of this method is preserved across shutdown and recovery. In other words, as long as you use the same recovery datastore, it does not matter how many times you restart the correlator. The result of invoking getUnique() will always be a unique number across all restarts.
This method starts by generating 0, 1, 2, 3, and so on. However, you cannot assume that you will receive the integer you might expect. The returned numbers are 64-bit signed integers.
For example, the following statement prints a different number every time the correlator executes it:
print integer.getUnique().toString();
Following are more examples:
monitor M {
   action onload() {
      integer i;
      i := integer.getUnique(); // called on type
      i := i.getUnique(); // called on instance
    }
}
*max(integer, integer)Returns as an integer the value of the larger operand. You can call this method on the integer type or on an instance of an integer type.
*min(integer, integer)Returns as an integer the value of the smaller operand. You can call this method on the integer type or on an instance of an integer type.
*parse(string)Returns the integer instance represented by the string argument. You can call this method on the integer type or on an instance of an integer type. The more typical use is to call parse() directly on the integer type.
The parse() method takes a single string as its argument. This string must be the string form of an integer object. The string must adhere to the format described in Event file format. For example:
integer a;
a := integer.parse("20080116");
You can specify the parse() method after an expression or type name. If the correlator is unable to parse the string, it is a runtime error and the monitor instance that the EPL is running in terminates.
*pow(integer)Returns as an integer the value of the operand to the power x (where x is the argument) or x, where i is the value of the operand. Note that negative values of x are not allowed, as these would generate floating point results.
*rand()Returns a random integer value from 0 up to (but not including) the value of the variable the method was invoked on. The following snippet of code would set B to a random value from 0 to 19:
integer A;
integer B;
A := 20;
B := A.rand();
while the next snippet would set B to a random value from -14 and 0:
integer A;
integer B;
A := -15;
B := A.rand();
When you are calling the rand() method on a variable, the method behaves correctly if the variable value is zero, that is (0).rand() returns 0.
Caution:  
This random number generator is not verified to be cryptographically strong. Therefore, it should not be used for purposes where a strong random number is required.
*toDecimal()Returns a decimal representation of the integer.
*toFloat()Returns a float representation of the integer.
*toString()Returns a string representation of the integer.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback