Decimal and EDecimal types

The EGL Decimal type is a value type if declared with parameters and is a non-instantiable reference type if declared without parameters. The type lets you create a packed decimal value. In Eclipse IDE for EGL Developers, the type definition for Decimal is EDecimal.

EGL package name

eglx.lang

Example use
After the following code runs, the value of result is 10.43, and the value of result02 is 10:
result   Decimal(4,2) = 10.43;
result02 Decimal(4)   = 10.43;
Type detail
In the following detail, the Operation annotation indicates that the specified operation is available. For example, use “==” to compare two values, not “$EQ”. Two exceptions are the widen and narrow operations, which are invoked during data conversions; for example, when the as operator is used.
/**
 * EDecimal defines the EGL decimal type.
 */
externalType EDecimal extends ENumber type ParameterizableType {
   parameterizedType = FixedPrecisionType}

/**
	 * {@Operation +} A unary plus (has no effect on the numeric value).
*/
static function $Plus(value EDecimal in) 
       returns (EDecimal) {@Operation{"+"}};

/**
	 * {@Operation +} Adds two numbers.
*/
static function $Plus(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EDecimal) {@Operation{"+"}};

/**
	 * {@Operation -} Negates the value.
*/
static function $Minus(value EDecimal in) 
       returns (EDecimal) {@Operation{"-"}};

/**
	 * {@Operation -} Subtracts one number from another.
*/
static function $Minus(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EDecimal) {@Operation{"-"}};

/**
	 * {@Operation *} Multiplies two numbers.
*/
static function $Multiply(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EDecimal) {@Operation{"*"}};

/**
	 * {@Operation /} Divides one number by another.
*/
static function $Divide(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EDecimal) {@Operation{"/"}};

/**
	 * {@Operation %} Computes the remainder of dividing one number by another.
*/
static function $Modulo(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EDecimal) {@Operation{"%"}};

/**
	 * {@Operation **} Computes lvalue to the power of rvalue.
*/
static function $PowerOf(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EFloat) {@Operation{"**"}};

/**
* {@Operation <} Compares two numbers.
*/
static function $LT(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EBoolean) {@Operation{"<"}};

/**
	 * {@Operation >} Compares two numbers.
*/
static function $GT(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EBoolean) {@Operation{">"}};

/**
	 * {@Operation <=} Compares two numbers.
*/
static function $LTE(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EBoolean) {@Operation{"<="}};

/**
	 * {@Operation >=} Compares two numbers.
*/
static function $GTE(lvalue EDecimal in, rvalue EDecimal in) 
       returns (EBoolean) {@Operation{">="}};

/**
	 * {@Operation ==} Compares two numbers.
*/
static function $EQ(lvalue EDecimal in, rvalue EDecimal in) 
       returns(EBoolean) {@Operation{"=="}};

/**
	 * {@Operation !=} Compares two numbers.
*/
static function $NEQ(lvalue EDecimal in, rvalue EDecimal in) 
       returns(EBoolean) {@Operation{"!="}};

/**
 * {@Operation widen} Converts a bigint to a decimal of arbitrary precision.
*/
static function asDecimal(value EBigint in) 
       returns(EDecimal) {@Operation{"widen"}};

/**
	 * {@Operation narrow} Converts a bigint to a decimal with the specified precision.
	 *
	 * @throws TypeCastException if the value can't be represented with the specified precision.
*/
static function asDecimal(value EBigint in, length EInt in, decimals EInt in)
       returns(EDecimal) {@Operation{"narrow"}};

/**
	* {@Operation narrow} Converts any decimal to a decimal with the specified precision.
*
* @throws TypeCastException if the value can't be represented with the specified precision.
*/
static function asDecimal(value EDecimal in, length EInt in, decimals EInt in)
       returns(EDecimal) {@Operation{"narrow"}};

/**
	 * {@Operation widen} Converts a smallint to a decimal of arbitrary precision.
*/
static function asDecimal(value ESmallint in) 
       returns(EDecimal) {@Operation{"widen"}};

/**
 * {@Operation narrow} Converts a smallint to a decimal with the specified precision.
 *
 * @throws TypeCastException if the value can't be represented with the specified precision.
*/
static function asDecimal(value ESmallint in, length EInt in, decimals EInt in)
       returns(EDecimal) {@Operation{"narrow"}};

/**
	 * {@Operation narrow} Converts a smallfloat to a decimal of arbitrary precision.
	 *
	 * @throws TypeCastException if the value is out of range.
*/
static function asDecimal(value ESmallfloat in) 
       returns(EDecimal) {@Operation{"narrow"}};

/**
 * {@Operation narrow} Converts a smallfloat to a decimal with the specified precision.
 *
 * @throws TypeCastException if the value can't be represented with the specified precision.
*/
static function asDecimal(value ESmallfloat in, length EInt in, decimals EInt in)
       returns(EDecimal) {@Operation{"narrow"}};

/**
	* {@Operation widen} Converts an int to a decimal of arbitrary precision.
*/
static function asDecimal(value EInt in) 
       returns(EDecimal) {@Operation{"widen"}};

/**
 * {@Operation narrow} Converts an int to a decimal with the specified precision.
 *
 * @throws TypeCastException if the value can't be represented with the specified precision.
*/
static function asDecimal(value EInt in, length EInt in, decimals EInt in) 
       returns(EDecimal) {@Operation{"narrow"}};

	/**
  * {@Operation narrow} Converts a float to a decimal of arbitrary precision.
  *
  * @throws TypeCastException if the value is out of range.
*/
static function asDecimal(value EFloat in) 
       returns(EDecimal) {@Operation{"narrow"}};

	/**
	 * {@Operation narrow} Converts a float to a decimal with the specified precision.
	 *
	 * @throws TypeCastException if the value is out of range.
	 */
	static function asDecimal(value EFloat in, length EInt in, decimals EInt in)
        returns(EDecimal) {@Operation{"narrow"}};
	
	/**
	 * {@Operation narrow} Converts a string to a decimal.  The string is parsed
	 * as follows: It may begin with an optional + or - sign.  After the sign there
	 * must be a sequence of one or more digit characters.  They may be followed by
	 * a decimal point (a period) and one or more digit characters.
	 *
	 * @throws TypeCastException if the string can't be parsed into a decimal.
	 */
	static function asDecimal(value EString in) 
        returns(EDecimal) {@Operation{"narrow"}};
	
static function asDecimal(value EString in, length EInt in, decimals EInt in)
       returns(EDecimal) {@Operation{"narrow"}};


static function asDecimal(value ENumber in) 
       returns(EDecimal) {@Operation{"narrow"}};

/**
	 * {@Operation widen} Converts a decimal to a number.
*/
static function asNumber(value EDecimal in) 
       returns(ENumber) {@Operation{"widen"}};
end
Comments
The type is fixed precision, parameterizable.
Compatibility
Table 1. Compatibility
Target Issue
Java No issues.
JavaScript No issues.