When calling a Java™ method with an expression evaluating to a DECIMAL , the runtime system converts the DECIMAL value to an instance of the com.fourjs.fgl.lang.FglDecimal class implemented in FGLDIR/lib/fgl.jar. You can then manipulate the DECIMAL from within the Java code.
You must add FGLDIR/lib/fgl.jar to the class path in order to compile Java code with com.fourjs.fgl.lang.FglDecimal class.
The com.fourjs.fgl.lang.FglDecimal class implements following:
| Method | Description |
|---|---|
String toString() |
Converts the DECIMAL value to a String object. |
static void valueOf(String val) |
Creates a new FglDecimal object from a String object representing a decimal value. |
static void valueOf(int val) |
Creates a new FglDecimal object from an int value. |
static int encodeTypeQualifier( int precision, int scale) |
Returns the encoded type qualifier
for this decimal according to precision and scale. encoded qualifier = (precision * 256) + scale Use 255 as scale for floating point decimal. |
public static FglDecimal divide(FglDecimal d1, FglDecimal d2){
BigDecimal bd1 = new BigDecimal(d1.toString());
BigDecimal bd2 = new BigDecimal(d2.toString());
BigDecimal res = bd1.divide(bd2, BigDecimal.ROUND_FLOOR);
return FglDecimal.valueOf(res.toString());
}
IMPORT JAVA com.fourjs.fgl.lang.FglDecimal
MAIN
DEFINE jdec com.fourjs.fgl.lang.FglDecimal
LET jdec = FglDecimal.valueOf("123.45")
DISPLAY jdec.toString()
END MAIN