Absolute value: abs
Syntax
abs ( op )
Input parameters
op |
the operand |
Examples of valid syntaxes
abs ( DS_1 )
abs ( -5 )
Semantics for scalar operations
The operator abs calculates the absolute value of a number. For example:
abs ( -5.49 )
gives 5.49
abs ( 5.49 )
gives 5.49
Input parameters type
op
dataset { measure<number> _+ }
| component<number>
| number
Result type
result
dataset { measure<number [ value >= 0 ]> _+ }
| component<number [ value >= 0 ]>
| number [ value >= 0 ]
Additional Constraints
None.
Behavior
The operator has the behaviour of the “Operators applicable on one Scalar Value or Data Set or Data Set Component” (see the section “Typical behaviours of the ML Operators”).
Examples
Given the operand dataset DS_1:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Me_1 |
Me_2 |
---|---|---|---|
10 |
A |
0.484183 |
0.7545 |
10 |
B |
-0.515817 |
-13.45 |
11 |
A |
-1.000000 |
187.0 |
Example 1
DS_r := abs ( DS_1 );
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
Me_2 |
---|---|---|---|
10 |
A |
0.484183 |
0.7545 |
10 |
B |
0.515817 |
13.45 |
11 |
A |
1.000000 |
187 |
Example 2
DS_r := DS_1 [ calc Me_10 := abs(Me_1) ];
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
Me_2 |
Me_10 |
---|---|---|---|---|
10 |
A |
0.484183 |
0.7545 |
0.484183 |
10 |
B |
-0.515817 |
-13.45 |
0.515817 |
11 |
A |
-1.000000 |
187.0 |
1.000000 |