Returns a value of 1 when the sign of a value is Positive, and a value of -1 when the sign of a value is negative.

 

Syntax:

Sign( AnyValue )

 

Parameter:

Description:

AnyValue

Any numeric value, Or numeric expression that results in a numeric value.

 

Example:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Simple Print Statement Examples
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRINT Sign( 13 )     '  Returns  1 - Indicating Sign is Positive
PRINT Sign( -13 )   '  Returns -1 - Indicating Sign is Negative
PRINT Sign( 2 * 2 ) '  Returns  1 - Indicating Sign is Positive
PRINT Sign( -2 * 2 ) '  Returns -1 - Indicating Sign is Negative

Or

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Control Sign of a Number
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Test this number
AnyNumber = 13
'  Show Number
PRINT "AnyNumber   ", AnyNumber ' Returns 13
 
'  Get Sign of AnyNumber
NumberSign = Sign( AnyNumber )
'  Show Number
PRINT "NumberSign  ", NumberSign ' Returns 1
 
'  Get Absolute Value of AnyNumber
AnyNumber = AnyNumber * NumberSign
PRINT "AnyNumber   ", AnyNumber ' Returns 13
 
'  Test this number
AnyNumber = -2 * 2
PRINT "AnyNumber   ", AnyNumber ' Returns -4
'  Assign Result of Sign Function
NumberSign = Sign( AnyNumber )
PRINT "NumberSign  ", NumberSign ' Returns -1
 
'  Use Sign Result to Absolute Value
AnyNumber = AnyNumber * NumberSign
PRINT "AnyNumber   ", AnyNumber ' Returns 4

 
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Show Sign of Last Calculation
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If Sign( AnyNumber ) = TRUE THEN
  PRINT "Sign( AnyNumber ) is Positive"
ELSE
  PRINT "Sign( AnyNumber ) is Negative"
ENDIF

 
Returns:
 

Returns:

Returns a 1 when the value is positive, and a -1 when the value is negative.

 

Links:

 

See Also:

Mathematical Functions

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 568

 

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software