Double Methods

Use Primavera Cloud Expression Language supported methods to manipulate decimal numbers of the type double.

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

Notes:

Double Methods

Method Signature

Description

Parameters

Example

Double.byteValue()

Returns the value of the Double calling the byteValue method represented as a byte.

No method parameters.

def x = 65.3;

def y = 77.8;

x.byteValue(); //returns 65

y.byteValue(); //returns 77

Double.compare(Double valueOne, Double valueTwo)

Compares the value of two Double arguments. Returns 0 if the arguments are equal, less than 0 if the first argument is less than the second, and greater than 0 if the first argument is greater than the second.

Double valueOne - First value to compare.

Double valueTwo - Second value to compare.

Double.compare(35.4, 22.1); //returns 1

Double.compare(35.4, 35.4); //returns 0

 

Double.compare(35.4, 42.1); //returns -1

Double.compareTo(Double value)

Compares the value of the Double calling the compareTo method with a Double passed as an argument. Returns 0 if the argument is equal to the Double calling the method, less than 0 if the Double calling the method is less than the argument, and greater than 0 if the Double calling the method is greater than the argument.

Double value - Value to compare against the Double calling the method.

def x = 35.4;

x.compareTo(100.0); // returns -1

x.compareTo(35.4); // returns 0

x.compareTo(22.1); // returns 1

Double.parseDouble(String string)

Returns a Double value matching the numeric value contained in the String passed as an argument.

String string - String to convert to a Double value.

Double.parseDouble("35.4"); //returns 35.4

Double.toString(Double value);

Returns a String representing the Double value passed as an argument.

Double value - Double value to convert to a String.

Double.toString(35.4); //returns "35.4"

Double.valueOf(String string)

Double.valueOf(Double value)

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

String string - String from which to extract a Double value.

Double value - Double object form which to extract a Double value.

Double.valueOf("35.4"); //returns 35.4

Double.valueOf(35.4); //returns 35.4

Additional Double Methods

Method Signature

Description

Parameters

Examples

Double.doubleValue()

Returns the value of the Double calling this method.

No method parameters.

def x = 12.5;

x.doubleValue(); //returns 12.5

Double.equals(Object obj)

Compares the double calling this method to the Object passed as an argument. Returns true if the argument is a Double value representing the same value as the Double calling the argument, otherwise returns false.

Object obj - An Object against which the Double calling the method is compared.

def x = 12.5;

x.equals(12.5); //returns true

x.equals(34.8); //returns false

x.equals("Hello"); //returns false

Double.floatValue()

Returns the float value of the Double calling this method.

No method parameters.

def x = 12.5;

x.floatValue(); //returns 12.5

Double.hashCode()

Returns a hash code for the Double calling this method.

No method parameters.

def x = 12.5;

x.hashCode(); //returns 1076428800

Double.intValue()

Returns the value of the Double calling this method as an Int type.

No method parameters.

def x = 12.5;

x.intValue(); //returns 12

Double.isInfinite()

Returns true if the Double calling this method is infinitely large, otherwise returns false.

No method parameters.

def x = 12.5;

x.isInfinite(); //returns false.

Double.isNaN()

Returns true if the Double calling this method is not a number, otherwise returns false.

No method parameters.

def x = 12.5

x.isNaN(); //returns false

Double.longValue()

Returns the value of the Double calling this method as a Long type.

No method parameters.

def x = 12.5;

x.longValue(); //returns 12

Double.shortValue()

Returns the value of the Double calling this method as a Short type.

No method parameters.

def x = 12.5;

x.shortValue(); //returns 12

Double.toHexString()

Returns the Double passed as an argument as a hexadecimal string.

Double value - Double to convert to a hexidecimal string.

Double.toHexString(12.5); //returns 0x1.9p3



Last Published Tuesday, May 21, 2024