LOGICAL

Purpose:

Converts the input to a logical integer or series.

Syntax:

LOGICAL(val)

val

-

A scalar, series or table.

Returns:

A logical integer or logical series.

Example:

logical(1.9)

 

returns the logical integer 1.

Example:

castlogical(1 + 2i)

 

returns the logical integer 1.

Example:

logical({1, 2, 0, -10, 100})

 

returns the logical series {1, 1, 0, 1, 1}.

Example:

a = {{3,  0,        100},

     {pi, sqrt(2),  exp(1)},

     {-3, sqrt(-3), 0}};

 

b = logical(a);

 

b == {{1, 0, 1},

      {1, 1, 1},

      {1, 1, 0}};

Example:

castlogical(0 + 0i)

 

returns the logical integer 0.

Example:

logical("string")

 

returns the logical integer 0.

Remarks:

LOGICAL returns a series for a series input and an integer for non-series inputs.

 

A logical series can be used to address a series. For example:

 

a = {1, 2, 3, 4, 5};

b = a > 3;

c = a[b];

 

c == {4, 5}

 

The values of a are returned whereever a > 3.

 

See CASTLOGICAL to convert the input into a logical integer.

See Also:

&& || ! AND OR NOT XOR (Logical Operators)

CASTCOMPLEX

CASTHANDLE

CASTLOGICAL

CASTREAL

CASTSERIES

CASTSTRING

CASTWINDOW

FIND

INT

ISLOGICAL