Integer Methods

Use Primavera Cloud Expression Language supported integer methods to manipulate numeric data of the integer type.

Refer to the official Java documentation for more information on each method.

Notes:

Integer Methods

Method Signature

Description

Parameters

Example

Integer.parseInt(String string)

Returns an Integer value representing the contents of the String passed as an argument.

String string - String from which to extract an integer value.

Integer.parseInt("45"); //returns 45

Integer.valueOf(String string)

Integer.valueOf(String string, Int radix)

Returns an Integer value representing the value of a String passed as an argument.

String string - String from which to extract an Integer value.

Int radix - Specifies the radix to use when converting the String argument into an Integer, for example, 2, 8, 16.

Integer.valueOf("45"); //returns 45

Integer.valueOf("101101", 2); //returns 45

Additional Integer Methods

Method Signature

Description

Parameters

Examples

Integer.bitCount(Int value)

Returns the number of one bits in the binary representation of the Int value passed as an argument.

Int value -Int value containing one bits to be counted.

Integer.bitCount(104); //returns 3

Integer.Compare(Int x, Int y)

Compares the value of the first Int passed as an argument to the value of the second Int passed as an argument. Returns 0 if the values are equal, returns less than 0 if the first argument is less than the second, and returns a value greater than 0 if the first argument is greater than the second.

Int x - The first Int value to compare.

Int y - The second Int value to compare.

Integer.compare(3,3); //returns 0

Integer.compare(3, 4); //returns -1

Integer.compare(4,3); //returns 1

Integer.decode(String number)

Returns the result of converting the String passed as an argument into an Int value. The argument String must be in decimal, hexadecimal, or octal format.

String number - String to convert into an Int value.

Integer.decode("24"); //returns 24

Integer.hashCode()

Returns a hash code representing the Integer calling this method.

No method parameters.

def x = 12;

x.hashCode(); //returns 12

Integer.highestOneBit(Int value)

Returns an Int value with at most a single one bit in the position of the leftmost one bit contained in the binary representation of the Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Integer.highestOneBit(12); //returns 8

Integer.lowestOneBit(Int value)

Returns an Int value with at most a single one bit in the position of the rightmost one bit contained in the binary representation of the Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Integer.lowestOneBit(12); //returns 4

Integer.numberOfLeadingZeros(Int value)

Returns the number of zeros preceding the leftmost one bit in the binary representation of the Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Integer.numberOfLeadingZeros(12); //returns 28

Integer.numberOfTrailingZeros(Int value)

Returns the number of zeros following the rightmost one bit in the binary representation of the Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Integer.numberOfTrailingZeros(12); //returns 2

Integer.reverse(Int value)

Returns the result of reversing the order of bits contained in the binary representation of the Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Integer.reverse(12); //returns 805306368

Integer.rotateLeft(Int value, Int distance)

Returns the result of rotating the binary representation of the Int value passed as an argument left by the value specified by the second Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Int distance - Number of places to rotate the binary representation of the first argument left.

Integer.rotateLeft(12, 4); //returns 192

Integer.rotateRight(Int value, Int distance)

Returns the result of rotating the binary representation of the Int value passed as an argument right by the value specified by the second Int value passed as an argument.

Int value - Integer value containing one bits in its binary representation.

Int distance - Number of places to rotate the binary representation of the first argument right.

Integer.rotateRight(12, 4); //returns -1073741824

Integer.signum(Int value)

Returns the signum function of the Int value passed as an argument. The signum value indicates whether an integer is positive, negative, or zero.

Int value - Int value against which to calculate signum.

Integer.signum(12); //returns 1

Integer.toBinaryString(Int value)

Returns a string representation of the binary representation of the Int value passed as an argument.

Int value - Integer value to convert to a binary representation.

Integer.toBinaryString(12); //returns "1100"

Integer.toHexString(Int value)

Returns a string representation of the hexadecimal representation of the Int value passed as an argument.

Int value - Integer value to convert to a hexadecimal representation.

Integer.toHexString(12); //returns "c"

Integer.toOctalString(Int value)

Returns a string representation of the octal representation of the Int value passed as an argument.

Int value - Integer value to convert to an octal representation.

Integer.toOctalString(); //returns 14



Last Published Tuesday, May 21, 2024