Sign

Not available in this language yet.
Sign( value )
Sign( value )
Sign( value )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Sign( value )

Description

The Sign function returns the sign of the argument as a numeric value.

Parameters

Argument Type Definition and Requirements

value

Number

Determine the sign of this number.

Returns

Long Values:

  • 1 when the value of the argument is positive.

  • 0 when the value of the argument is zero.

  • -1 when the value of the argument is negative.

Double Values:

  • -1 when the value of the argument is less than zero.

  • 1 when the value is greater than or equal to zero or NaN.

Examples

The query below executes an array of independent sign operations and returns the results in an array. The result array position matches the execution array position. The first sign operation on the value 3 returns 1 for a positive number. The second operation returns zero for neither a positive nor negative number. The third sign operation on the value -3 returns -1 for a negative number.

System.out.println(
    client.query(
        Arr(
            Sign(Value(3)),
            Sign(Value(0)),
            Sign(Value(-3))
        )
    ).get());
client.query([
  q.Sign(3),
  q.Sign(0),
  q.Sign(-3),
])
.then((ret) => console.log(ret))
println(Await.result(
  client.query(
    Arr(
      Sign(3),
      Sign(0),
      Sign(-3),
    )
  ),
  5.seconds
))
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
[1, 0, -1]
[ 1, 0, -1 ]
[1, 0, -1]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!