sqrt, cbrt - Square and Cube Roots

Prev Next

Function Names

sqrt, cbrt

Description

Function sqrt:If the input value is a positive number, then the square root will be calculated. If negative, a void value will be returned.
Function cbrt:Calculates the cube root

Non-numeric values (including dates) 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.

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 or set containing multiple values (vectorization)

Return value

TypeDescription
all types
set
Result

Calculated value(s)

Examples

               echo( sqrt( 4 ) );
               echo( sqrt( 2 ) );
               echo( sqrt( {1,4,9,16,25} ) ); // Vectorization
               echo( sqrt( {"", "Text", 2, -2, date(today)} ) ); // Vectorization, non-numeric values will bypass

Output

2
1.4142135624
{1,2,3,4,5}
{'','Text',1.4142135624,# Negative Square Root #,'2024-10-19'}
Try it yourself: Open LIB_Function_sqrt.b4p in B4P_Examples.zip. Decompress before use.

See also

Power Functions