abs - Absolute Value

Prev Next

Function Names

abs

Description

Derives the absolute value. Functional behavior depends on basic data types provided:


Strings (including blanks) are passed through without modifications. This is particularly suitable in combination with vectorization in order to pass through blank contents, explanatory text, etc.

Vectorization: This function supports vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

data type Description
numeral Turns number positive
string Passed through
date Returns Microsoft Excel serial date. If time is provided, then time is the fraction of the day (e.g. 0.5 for 12:00 noon time).
boolean Returns 0 if false, 1 if true
void Passed through
set The absolute values of the elements in the set will be derived (vectorization).

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
all types
set
Value

Value to convert to absolute value

Return value

TypeDescription
all types
set
Absolute value

Absolute value(s) as calculated using rules described above

Examples

               echo( abs(-1) );
               echo( abs(true) );
               echo( abs(Hello World) );
               echo( abs(date(today)) );
               echo( abs(date(now)) );
               echo( abs(time(now)) );

Output

1
1
Hello World
45584
45584.9125810185
0.9125810185
Try it yourself: Open LIB_Function_abs.b4p in B4P_Examples.zip. Decompress before use.