>  Docs Center  >  IDL Reference  >  Array Manipulation  >  SIGNUM



The SIGNUM function returns the sign of each element of an array. The sign of a value X is defined as:

  • 1 if X > 0
  • 0 if X = 0
  • -1 if X < 0
  • If X is complex then the sign is defined as X/abs(X).
  • If X is NaN (not-a-number) then the result is also NaN.


Find the sign of each element in an array:

print, SIGNUM([-0.5, 0, 1.5])

IDL prints:

-1.00000      0.000000       1.00000

Plot the cosine function and the sign of the function:

p1 = PLOT('cos(x)', '2--', YRANGE=[-1.5,1.5])
p2 = PLOT('signum(cos(x))', '2', /OVERPLOT)
p1['axis 1'].showtext = 0
p1['axis 3'].showtext = 1


Result = SIGNUM(X)

Return Value

Returns a scalar or array of the same type and dimensions as the input. If X is a string then the values are converted to single-precision floating point before computing the sign.



A scalar or array of any numeric data type. String values are converted to single-precision floating point.


Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History



See Also


© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us