# coyote: BINARY

- coyote/Utilities
- [Source code]

NAME

      BINARY

PURPOSE

      This function is used to display a binary representation of byte,
      integer, and long integer values.

AUTHOR

      FANNING SOFTWARE CONSULTING
      David Fanning, Ph.D.
      1645 Sheely Drive
      Fort Collins, CO 80526 USA
      Phone: 970-221-0438
      E-mail: david@idlcoyote.com
      Coyote's Guide to IDL Programming: http://www.idlcoyote.com/

CATEGORY

      Utilities

CALLING SEQUENCE

      output = Binary(theNumber)

RETURN VALUE

      output:        A string array of 0s and 1s to be printed (normally), in a
                     binary representation of the number. The number is represented with
                     the highest bits on the left and the lowest bits on the right,
                     when printed with the PRINT command.

ARGUMENTS

      theNumber:      The number for which the user wants a binary representation.
                      It must be BYTE, INT, or LONG.

KEYWORDRS

      COLOR:          If this keyword is set, the binary representation always
                      contains 24 bits of output.
      SEPARATE:       If this keyword is set, the output is separated with space
                      between each group of eight bits.

EXAMPLE

      IDL> Print, Binary(24B)
              0 0 0 1 1 0 0 0
      IDL> Print, Binary(24L)
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
      IDL> Print, Binary(24L, /COLOR)
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
      IDL> Print, Binary(24L, /COLOR, /SEPARATE)
              0 0 0 0 0 0 0 0    0 0 0 0 0 0 0 0    0 0 0 1 1 0 0 0

MODIFICATION HISTORY

      Written by: David W. Fanning, November 10, 2007.
      Fixed a problem with error handling. 13 March 2008. DWF.