sub_or_null - ObjectVision/GeoDMS GitHub Wiki
Arithmetic functions sub_or_null
- sub_or_null(a, b)
sub_or_null(a, b) results in the element-by-element subtraction of corresponding values of the data items: a and b. If the result of the addition exceeds the MinValue or MaxValue of the value type, the sub_or_null function results in the value null.
Data items with Numeric, Point, or String value type.
- Domain units of the arguments must match or be void, (literals or parameters can be added to data items of any domain).
- Arguments must have matching:
- value type
- metric
1. attribute<uint8> sub_or_null_AB (ADomain) := sub_or_null(A, B);
A | B | sub_or_null_AB |
---|---|---|
0 | 1 | null |
1 | null | null |
200 | 54 | 146 |
50 | 100 | null |
222 | 111 | 111 |
ADomain, nr of rows = 5
Old situation giving numeric overflow issues:
attribute<string> prev_name := MakeDefined(name[id(.) -1b], 'StartingYear');
With the new sub_or_null() operator:
attribute<string> prev_name := MakeDefined(name[sub_or_null(id(.),1b)], 'StartingYear');
Preferred backwards compatible option:
attribute<string> prev_name := id(.) >= 1b ? name[id(.) - min_elem( id(.), 1b)] : 'StartingYear';
Alternative, which looks more like the old one:
attribute<string> prev_name :=
MakeDefined(name[id(.) >= 1b ? id(.) - min_elem(id(.), 1b) : 0b/0b], 'StartingYear');