FUNCTIONS CORE

Sign()

Convert the sign of a number to a numeric value

Syntax

Signature
Sign( nNumber ) --> nSign

Arguments

nNumber

Example

Sign.prg
PROCEDURE Main()

   Check( 'Sign( 48335 ) ', Sign( 48335 ), 1 )
   Check( 'Sign( -258 )  ', Sign( -258 ), -1 )
   Check( 'Sign( 0 )     ', Sign( 0 ), 0 )
   Check( 'Sign( -0.5 )  ', Sign( -0.5 ), -1 )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

Sign( 48335 ) OK
Sign( -258 )  OK
Sign( 0 )     OK
Sign( -0.5 )  OK