POWER Function (NUMBERS)
This is a default function given in CAL that raises a number to a power.
Ex: NewNumber := POWER(Base,Power);
POWER(2,8) => 256
POWER(100,0) => 1
ROUND Function (NUMBERS)
Rounds the value of Numeric Variables.
Ex: NewNumber := ROUND(Number,[..Precision],[..Direction])
DecimalToRound := 1234.56789;
Precision := 0.001;
Direction := '>';
Result := ROUND( DecimalToRound,Precision ,Direction ) ;
MESSAGE(ROUND(%1 ,%2 ,%3 ) returns %4 ,DecimalToRound,Precision,Direction,Result );
The message will shown like this.
"ROUND(1,234.56789, 0.001, >) returns 1,234.568"
The following table will show some additional ROUND examples.
Number
|
Precision
|
Direction
|
Rounded number
|
1234.56789
|
100
|
=
|
1200
|
1234.56789
|
0.1
|
=
|
1234.6
|
1234.56789
|
0.001
|
=
|
1234.568
|
1234.56789
|
0.001
|
<
|
1234.567
|
1234.56789
|
0.001
|
>
|
1234.568
|
-1234.56789
|
100
|
=
|
-1200
|
-1234.56789
|
0.1
|
=
|
-1234.6
|
-1234.56789
|
0.001
|
=
|
-1234.568
|
-1234.56789
|
0.001
|
<
|
-1234.567
|
-1234.56789
|
0.001
|
>
|
-1234.568
|
When you round down ('<') a negative number, the following occurs: -1234.56789 is rounded down to -1234.567. However, -1234.567 is a mathematically greater value than -1234.56789.
When you round up ('>') a negative number, the following occurs: -1234.56789 is rounded up to -1234.568. However, -1234.568 is a mathematically smaller value than -1234.56789.
ABS Function (NUMBER)
Calculate the absolute value of a number (Decimal, Integer or Bigint) . This function also returns of
positive and zero values only.
Ex: NewNumber := ABS(Number);
x := -10.32;
y := ABS(x);
MESSAGE('x is %1 y is %2');
The message will show "x is -10.32 y is 10.32".
EVALUATE Function (NUMBER)
Evaluates a string representation of a value into its normal representation. The result is assign to a variable.
Ex : [..ok] := EVALUATE(Variable,String[,Number]);
Text000 'VarInteger = #1###### , and the return code is %2\'
Text001 'VarDate = #3###### , and the return code is %4\'
Text002 'VarYesNo = #5###### , and the return code is %6\'
Value := '010196';
Ok1 := EVALUATE (VarInteger,Value);
Ok2 := EVALUATE (VarDate,Value);
Ok1 := EVALUATE (VarYesNo,Value);
MESSAGE (Text000 + Text001 + Text002 , VarInteger, Ok1, VarDate, Ok2 , VarYesNo, Ok3);
The message will show you.
"
VarInteger = 10196 , and the return code is: YesVarDate = 01/01/96, and the return code is: YesVarYesNo = No , and the return code is: No "
Thank you.
Regards,
Dinuka.
No comments:
Post a Comment