abs - Absolute Value

Prev Next

Function Names

abs

Description

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

data type Description
numeral Turns number positive
string Returns 0 all time
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
parameter set Activates indirect parameter passing. Parameter set must contain 1 element of type described above.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
valid types Value

Value to convert to absolute value

Return value

TypeDescription
numeral Absolute value

Absolute value 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
0
45487
45487.4227199074
0.4227199074
Try it yourself: Open LIB_Function_abs.b4p in B4P_Examples.zip. Decompress before use.