- If the digit in the first removed decimal place is a 0, 1, 2, 3 or 4, then the value will be rounded down.
- If the digit in the first removed decimal place is a 5, 6, 7, 8 or 9, then the value will be rounded up.
- Negative numbers are rounded according to their amount, i.e. from the number 5 away from zero.

12,3449 -> 12,34

12,3450 -> 12,35

-12,3449 -> -12,34

-12,3450 -> -12,35

For business rounding, Intrexx provides the method "roundHalfAwayFromZero(double, precision)" and "roundHalfAwayFromZero(BigDecimal, precision)". The second parameter "precision" defines the number of decimal places and is optional.

- If the last digit to be retained is followed by a 0, 1, 2, 3 or 4, the value will be rounded down.
- If the last digit to be retained is followed by a 5, 6, 7, 8 or 9, followed by further digits which are not all zero, then the value will be rounded up.
- If the last digit to be retained is followed by a 5 alone (or a 5 with only zeroes following), then the rounding is such that the last retained digit is even.

1,2499 -> 1,2

1,2501 -> 1,3

1,2500 -> 1,2

1,3500 -> 1,4

For mathematical rounding, Intrexx offers you the "$Math.roundHalfEven()" method.

```
$Math.roundHalfUp(0.5) == 1.0
$Math.roundHalfUp(-0.5) == 0.0
```

```
$Math.roundHalfAwayFromZero(0.5) == 1.0
$Math.roundHalfAwayFromZero(-0.5) == -1.0
```

```
$Math.roundHalfEven(1.5) == 2.0
$Math.roundHalfEven(-1.5) == -2.0
$Math.roundHalfEven(0.12) == 0.0
$Math.roundHalfEven(0.61) == 1.0
$Math.roundHalfEven(-0.61) == -1.0
```

The two methods roundHalfAwayFromZero() and roundHalfEven() accept
an optional second transfer parameter to specify the rounding accuracy.
Here you can specify the number of decimal places that the value should be
rounded to. Negative values can also be applied, to influence the accuracy
before the decimal point.
```
$Math.roundHalfUpAsInt(double)
$Math.roundHalfUpAsLong(double)
```

Naturally, there are also universal cast methods provided by the
$Math object. These include:
```
$Math.toInteger(java.lang.Object p_value)
$Math.toLong(java.lang.Object p_value)
$Math.toFloat(java.lang.Object p_value)
$Math.toDouble(java.lang.Object p_value)
$Math.toBigDecimal(java.lang.Object p_value)
```

Each of these methods accepts a transfer parameter of the java.lang.Object
type, so that (among others) character strings can also be transferred and
transformed. However, in the case of strings, no delimiters such as
thousand separators, or decimal separators, can be included.
You also always have the option to specify a fallback value of the
appropriate type. If a transformation fails, this fallback value will be
returned. Any overflows that may occur in casting can also be
captured with the help of these methods.