|
Application Programming: Working with Data in IDL |
|
The IDL language is dynamically typed. This means that an operation on a variable can change that variable's type. In general, when variables of different types are combined in an expression, the result has the data type that yields the highest precision. For example, if an integer variable is added to a floating-point variable, the result will be a floating-point variable. See Data Type and Structure of Expressions
| Note See Returning Type and Size Information for information on how to determine the data type of an array. |
In IDL there are twelve basic, atomic data types, each with its own form of constant. The data type assigned to a variable is determined either by the syntax used when creating the variable, or as a result of some operation that changes the type of the variable. IDL's basic data types are discussed in more detail beginning with Defining and Using Constants
Table 13-1 lists IDL's basic data types, provides examples of how to explicitly create a variable of each type, and list the routines used to create variables and arrays of each type.
| Note In previous versions of IDL prior to version 4, the combination of a double-precision number and a complex number in an expression resulted in a single-precision complex number because those versions of IDL lacked the DCOMPLEX double-precision complex data type. Starting with IDL version 4, this combination results in a DCOMPLEX number. |
The precision of IDL's floating-point numbers depends somewhat on the platform involved and the compiler and specific compiler switches used to compile the IDL executable. The values shown here are minimum values; in some cases, IDL may deliver slightly more precision than we have indicated. If your application uses numbers that are sensitive to floating-point truncation or round-off errors, or values that cannot be represented exactly as floating-point numbers, this is something you should consider.
For more information on floating-point mathematics, see Mathematics. For information on your machine's precision, see MACHAR.
IDL Online Help (March 06, 2007)