Difference between revisions of "Mathematical Operators"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(4 intermediate revisions by one user not shown)
Line 7: Line 7:
 
|()||Parentheses||1||N,C,D
 
|()||Parentheses||1||N,C,D
 
|-
 
|-
|**||Exponentiation||2||N
+
|**||Exponentiation||2||N
 
|-
 
|-
|*||Multiplication||3||N
+
|*||Multiplication||3||N
 
|-
 
|-
 
|/||Division||3||N
 
|/||Division||3||N
Line 15: Line 15:
 
|%||Modulus/Remainder||3||N
 
|%||Modulus/Remainder||3||N
 
|-
 
|-
|+||Addition||4||N,C,D
+
|+||Addition||4||N,C,D
 
|-
 
|-
|-||Subtraction||4||N,C,D
+
|-||Subtraction||4||N,C,D
 
|-
 
|-
 
|}
 
|}
Line 23: Line 23:
  
 
When dealing with Character data types, the operators have the following definitions:  
 
When dealing with Character data types, the operators have the following definitions:  
 +
  
 
{| class="wikitable"
 
{| class="wikitable"
 
!Operator||Operation
 
!Operator||Operation
 
|-
 
|-
|+||Concatenate the right hand string to the end of the left hand string
+
|+||Concatenate the right hand string to the end of the left hand string.
 
|-
 
|-
|-||Concatenate the right hand string to the end of the left hand string after trimming the left hand string of trailing spaces
+
|-||Concatenate the right hand string to the end of the left hand string after trimming the left hand string of trailing spaces.
 +
|-
 +
|}
 +
 
 +
 
 +
When dealing with Date data types, the operators have the following definitions:
 +
 
 +
 
 +
{| class="wikitable"
 +
!Operator||Operation
 +
|-
 +
|&#043;||<expD> + <expN> returns a date plus the number of days specified in <expN>.
 +
|-
 +
|&#045;||Returns the interval between the two dates as a number of days.
 
|-
 
|-
 
|}
 
|}
Line 42: Line 56:
 
? [Hello    ] - [ World]
 
? [Hello    ] - [ World]
 
Hello World
 
Hello World
 +
? date() + 30 - date()
 +
        30
 
</code>
 
</code>
 +
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Reference]]
 
[[Category:Reference]]

Latest revision as of 13:26, 24 March 2009

The Recital/4GL supports the use of the following Mathematical Operators:


Operator Operation Precedence Data Types
() Parentheses 1 N,C,D
** Exponentiation 2 N
* Multiplication 3 N
/ Division 3 N
% Modulus/Remainder 3 N
+ Addition 4 N,C,D
- Subtraction 4 N,C,D


When dealing with Character data types, the operators have the following definitions:


Operator Operation
+ Concatenate the right hand string to the end of the left hand string.
- Concatenate the right hand string to the end of the left hand string after trimming the left hand string of trailing spaces.


When dealing with Date data types, the operators have the following definitions:


Operator Operation
+ <expD> + <expN> returns a date plus the number of days specified in <expN>.
- Returns the interval between the two dates as a number of days.


Example

? 2*3^2
        18
? 2*25%7
      1.00
? [Hello     ] - [ World]
Hello World
? date() + 30 - date()
        30