Sign
Syntax:¶
SIGN(number)
- number: A numeric value whose sign you want to determine. This can be positive, negative, or zero.
Description:¶
The SIGN function in Excel returns the sign of a number. It indicates whether the number is positive, negative, or
zero, and returns:
1if the number is positive-1if the number is negative0if the number is zero
Examples:¶
SIGN(10)would return1because10is positive.SIGN(-5.5)would return-1because-5.5is negative.SIGN(0)would return0because the number is zero.SIGN(-0.001)would return-1because even small negative values are treated as negative.
Notes:¶
- The Rust implementation provided uses the
f64data type for the input and returns ani32value to match the results of theSIGNfunction in Excel. - This implementation can handle both integer and floating-point numbers as long as they are converted to
f64. - If the input is
NaNor infinity (f64::NANorf64::INFINITY), you might want to handle these cases separately based on your application's requirements.