Previous Application Programming: Working with Data in IDL Next

Data Types

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.

Basic Data Types

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.

Table 13-1: Data Types 

Table 13-1: Data Types 
Data Type
Description
Creation
Routines
Byte
An 8-bit unsigned integer ranging in value from 0 to 255. Pixels in images are commonly represented as byte data.
a = 5B  
a = BYTE(5)  
Integer
A 16-bit signed integer ranging from -32,768 to +32,767.
b = 0  
b = 0S  
b = FIX(0)  
FIX
Unsigned Integer
A 16-bit unsigned integer ranging from 0 to 65535
c = 0U  
c = UINT(0)  
Long
A 32-bit signed integer ranging in value from approximately minus two billion to plus two billion.
d = 0L  
d = LONG(0)  
Unsigned Long
A 32-bit unsigned integer ranging in value from 0 to approximately four billion.
e = 0UL  
e = ULONG(0)  
64-bit Long
A 64-bit signed integer ranging in value from –9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
f = 0LL  
f = LONG64(0)  
64-bit Unsigned Long
A 64-bit unsigned integer ranging in value from 0 to 18,446,744,073,709,551,615.
g = 0ULL  
g = ULONG64(0)  
Floating-point
A 32-bit, single-precision, floating-point number in the range of ±1038, with approximately six or seven decimal places of significance.
h = 0.0  
h = FLOAT(0)  
Double-precision
A 64-bit, double-precision, floating-point number in the range of ±10308 with approximately 14 decimal places of significance.
i = 0.0D  
i = DOUBLE(0)  
Complex
A real-imaginary pair of single-precision, floating-point numbers. Complex numbers are useful for signal processing and frequency domain filtering.
j = $
COMPLEX(1.0, 0.0)  
j = COMPLEX(1,0)  
Double-precision complex
A real-imaginary pair of double-precision, floating-point numbers.
k = $
DCOMPLEX(1.0, 0.0)  
String
A sequence of characters, from 0 to 2147483647 (2.1 GB) characters in length, which is interpreted as text.
l = 'Hello'  
l = $
STRING([72B, 101B, $  
108B, 108B, 111B])  


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.

Precision of Floating-Point Numbers

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.

Complex Data Types

  IDL Online Help (March 06, 2007)