The following example demonstrates how the rounding functions work together. These functions include the following:
FLOOR
- largest integer that is not greater than the input value. See FLOOR Function.CEILING
- smallest integer that is not less than the input value. See CEILING Function.ROUND
- nearest integer to the input value. See ROUND Function.MOD
- remainder integer when input1 is divided by input2. See Numeric Operators.
Source:
rowNum | X |
---|
1 | -2.5 |
2 | -1.2 |
3 | 0 |
4 | 1 |
5 | 1.5 |
6 | 2.5 |
7 | 3.9 |
8 | 4 |
9 | 4.1 |
10 | 11 |
Transformation:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'floorX' |
---|
Type | step |
---|
WrangleText | derive type: single value: FLOOR (X) as: 'floorX' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | FLOOR(X) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'ceilingX' |
---|
Type | step |
---|
WrangleText | derive type: single value: CEILING (X) as: 'ceilingX' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | CEILING(X) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'roundX' |
---|
Type | step |
---|
WrangleText | derive type: single value: ROUND (X) as: 'roundX' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | ROUND (X) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'modX' |
---|
Type | step |
---|
WrangleText | derive type: single value: (X % 2) as: 'modX' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | (X % 2) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Results:
rowNum | X | modX | roundX | ceilingX | floorX |
---|
1 | -2.5 | | -2 | -2 | -3 |
2 | -1.2 | | -1 | -1 | -2 |
3 | 0 | 0 | 0 | 0 | 0 |
4 | 1 | 1 | 1 | 1 | 1 |
5 | 1.5 | | 2 | 2 | 1 |
6 | 2.5 | | 3 | 3 | 2 |
7 | 3.9 | | 4 | 4 | 3 |
8 | 4 | 0 | 4 | 4 | 4 |
9 | 4.1 | | 4 | 5 | 4 |
10 | 11 | 1 | 11 | 11 | 11 |