# coyote: CONVERT_TO_TYPE

- coyote/Utilities
- [Source code]

NAME

      CONVERT_TO_TYPE

PURPOSE

      Converts its input argument to a specified data type.

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

      result = Convert_To_Type(input, type)

INPUT_PARAMETERS

      input:          The input data to be converted.
      type:           The data type. Accepts values as given by Size(var, /TNAME) or Size(var, /TYPE).
                      If converting to integer types, values are truncated (similar to FLOOR keyword below),
                      unless keywords are set.

OUTPUT_PARAMETERS

      result:          The input data is converted to specified data type.

KEYWORDS

      CEILING:          If set and converting to an integer type, the CEIL function is applied before conversion.
      FLOOR:            If set and converting to an integer type, the FLOOR function is applied before conversion.
      ROUND:            If set and converting to an integer type, the ROUND function is applied before conversion.

RESTRICTIONS

      Data types STRUCT, POINTER, and OBJREF are not allowed.

MODIFICATION HISTORY

      Written by David W. Fanning, 19 February 2006.
      Typo had "UNIT" instead of "UINT". 23 February 2009. DWF.
      Added CEILING, FLOOR, and ROUND keywords. 1 April 2009. DWF.
      Modified so that the "type" variable is not changed by the program. 5 May 2009. DWF.