  User login Username: * Password: Remember me Frontpage Sponsor   Poll How big is your Baan-DB (just Data AND Indexes)0 - 200 GB17%200 - 500 GB29%500 - 800 GB3%800 - 1200 GB7%1200 - 1500 GB7%1500 - 2000 GB13%> 2000 GB23%Total votes: 69

 Arithmetic operators
By patvdv at 26 Feb 2008 - 21:56

## Arithmetic operators

Arithmetic operators perform arithmetic operations on the operands. All arithmetic operators, except string concatenation, must have operands of numerical type. If one of the two operands is a double, the other is also converted to double, and the result is also of double type. For example:

```  45/30 is equal to 1
| 45 and 30 are both LONG so the result is LONG
45/30.0 is equal to 1.5
| 30.0 is a DOUBLE so the result is a DOUBLE

```

The concatenation operator concatenates expressions, variables, or constants of string type.

### Examples

```        LONG lng_1, lng_2
DOUBLE doub
STRING strg_1(16), strg_2(50), strg_3(10), strg_4(20)

```
Expression Result
```lng_2 = 8
```
The variable lng_2 contains 2, which is the remainder after dividing 8 by 3..
```lng_1 = lng_2 + 3
```
The variable lng_1 now contains 5.
```doub = lng_1 * 2.0
```
The variable lng_1 is multiplied by 2.0; the result (10.0) is stored in doub.
```doub = 45 / 30
```
The variable doub now equals 1.0.

Note that 45 and 30 are both longs, so the result of the expression is 1. Converted to double for storing in the result, this becomes 1.0.
```doub = 45 / 30.0
```
The variable doub now contains 1.5.
```strg_1 = "hel" & "lo"
```

The variable strg_1 now contains the value "hello".

``` strg_2 = strg_3 & strg_4
```

The contents of strg_3 and strg_4 are concatenated and placed in strg_2.

### Related topics  ©2001-2018 - Baanboard.com - Baanforums.com