Math.Sign Method

Returns a number that indicates the sign of a specified value.

...Math.Sign (value)

Prerequisites

None

Parameters

value

A required expression that evaluates to any numerical data type, e.g. Integer, Single, Double.

Remarks

Returns a 1.0 if the value is greater than zero, 0 if the value is equal to zero, otherwise –1.0 to indicate that the value is negative.

Examples

Dim v_sign As Single, int_v_sign As Integer
v_sign = Math.Sign(-21.2/(-2.3)) ' Sets v_sign equal to 1.0
int_v_sign = Math.Sign(-7.2) ' Sets int_v_sign equal to –1

See Also

Math Class