@Sign (Formula Language)

Indicates whether a number is positive, negative, or zero.

Syntax

@Sign( signedNumber )

Parameters

signedNumber

Number or number list. The number whose sign you want to determine.

Return value

sign

Number or number list. May be any of the following values:

  • The signed numberis negative, - 1
  • The signed number is zero, 0
  • The signed numberis positive, 1

Usage

If the parameter is a list, the function operates on each element of the list, and the return value is a list with the same number of elements.

Examples

  1. This formula sets the result field to "Profit!" if the earnings field is greater than the expenses field, "Loss!" if expenses are greater than earnings, and "Break even" if they are equal.
    field result:=result;
    difference:=earnings - expenses;
    r:=@If( ( @Sign( difference ) = 1); "Profit!"; ( @Sign( difference ) = -1 ); "Loss!"; "Break even" ); @SetField( "result"; r )
  2. This formula allows division by a positive number but returns -1 if the divisor is negative and 0 if the divisor is 0. If number1 and number2 are lists, the result is a list.
    @If(@Sign(number2) = 1; number1 / number2; @Sign(number2) = -1; -1; 0)