w3resource

Oracle SIGN() function

Description

The SIGN() returns the sign of an argument.

This function is used to return the sign of a given number. This function takes as an argument any numeric data type and any nonnumeric data can also comes in the argument but that can be implicitly converted to number and returns number.

The function returns:

  • 1 when the value of the argument is positive
  • -1 when the value of the argument is negative
  • 0 when the value of the argument is 0

For binary floating-point numbers (BINARY_FLOAT and BINARY_DOUBLE), this function returns the sign bit of the number. The sign bit is:

  • -1 if n<0
  • +1 if n>=0 or n=NaN
Uses of Oracle SIGN() Function
  • Determine the sign of a number: Identify if a number is positive, negative, or zero.

  • Conditional logic: Use in conditional statements to execute different logic based on the sign of a number.

  • Mathematical operations: Assist in various mathematical computations where the sign of a number influences the result.

  • Data analysis: Facilitate data analysis by categorizing numbers based on their sign.

  • Binary floating-point operations: Return the sign bit of binary floating-point numbers.

Syntax:

SIGN(n)

Parameters:

Name Description
n A number whose sign is to be retrieved.

Pictorial Presentation of SIGN() function

Pictorial Presentation of Oracle SIGN() function

Example:

SELECT SIGN(-145), SIGN(0), SIGN(145) FROM dual;

Here is the result.

SIGN(-145)    SIGN(0)  SIGN(145)
---------- ---------- ----------
        -1          0          1

The above statement will return the sign of given numbers -145, 0 and 145.

Previous: ROUND
Next: SIN



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/oracle/oracle-numeric-functions/oracle-sign-function.php