Skip to main content

SIGNBIT

Description

Determine whether the sign bit of the given floating-point number is set.

Syntax

SIGNBIT(<a>)

Parameters

ParameterDescription
<a>Floating-point number to check the sign bit for

Return Value

Returns true if the sign bit of <a> is set (i.e., <a> is negative), otherwise returns false. Specifically, it can also distinguish between positive and negative zeros in floating-point numbers.

Examples

select signbit(-1.0);
+---------------+
| signbit(-1.0) |
+---------------+
| 1 |
+---------------+
select signbit(0.0);
+--------------+
| signbit(0.0) |
+--------------+
| 0 |
+--------------+
select signbit(1.0);
+--------------+
| signbit(1.0) |
+--------------+
| 0 |
+--------------+
select signbit(cast('+0.0' as double)) , signbit(cast('-0.0' as double));
+---------------------------------+---------------------------------+
| signbit(cast('+0.0' as double)) | signbit(cast('-0.0' as double)) |
+---------------------------------+---------------------------------+
| 0 | 1 |
+---------------------------------+---------------------------------+