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.
In addition, IDL provides several compound data types that serve as containers for variables of other data types. Examples of compound data types include pointers, structures, objects, lists, and hashes. You cannot create a constant of a compound data type, but it is generally possible to create an “empty” variable of a compound data type. See Compound Data Types for additional information.
Finally, there is the special !NULL system variable, which represents an undefined variable.
The following table lists IDL’s 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. Type codes shown in the Type Code column correspond to the type code returned by the SIZE function. Type names shown in the Type Name column correspond to the string returned by the TYPENAME function.
Data Type |
Description |
Type |
Type Name |
Creation |
Routines |
---|---|---|---|---|---|
Null | An undefined variable. !NULL may be used for array concatenation, array indexing, and for comparison. | 0 | UNDEFINED |
a = !NULL
a = [ ]
a = { } |
!NULL |
An 8-bit unsigned integer ranging in value from 0 to 255. Pixels in images are commonly represented as byte data. |
1 |
BYTE |
a = 5B
a = BYTE(5) |
||
A 16-bit signed integer ranging from -32,768 to +32,767. |
2 |
INT |
b = 0
b = 0S
b = FIX(0) |
||
A 16-bit unsigned integer ranging from 0 to 65535. |
12 |
UINT |
c = 0U
c = UINT(0) |
||
A 32-bit signed integer ranging in value from |
3 |
LONG |
d = 0L
d = LONG(0) |
||
A 32-bit unsigned integer ranging in value from 0 to 4 294 967 296. |
13 |
ULONG |
e = 0UL
e = ULONG(0) |
||
A 64-bit signed integer ranging in value from |
14 |
LONG64 |
f = 0LL
f = LONG64(0) |
||
A 64-bit unsigned integer ranging in value from 0 to 18 446 744 073 709 551 615. |
15 |
ULONG64 |
g = 0ULL
g = ULONG64(0) |
||
A 32-bit, single-precision, floating-point number in the range of ±1038, with approximately six or seven significant digits. |
4 |
FLOAT |
h = 0.0
h = FLOAT(0) |
||
A 64-bit, double-precision, floating-point number in the range of ±10308 with approximately 14 significant digits. |
5 |
DOUBLE |
i = 0.0D
i = DOUBLE(0) |
||
A real-imaginary pair of single-precision, floating-point numbers. Complex numbers are useful for signal processing and frequency domain filtering. |
6 |
COMPLEX |
j = $
j = COMPLEX(1,0) |
||
A real-imaginary pair of double-precision, floating-point numbers. |
9 |
DCOMPLEX |
k = $ |
||
A sequence of characters, from 0 to 2 147 483 647 (2.1 GB) characters in length, which is interpreted as text. |
7 |
STRING |
l = 'Hello'
l = $ 108B, 108B, 111B]) |
||
A compound data type that contains pairs of tags and values, where the values can be of any data type. Once a structure is created, neither the tags nor the data types of the values associated with the tags can be changed. |
8 |
Structure name or ANONYMOUS |
s = {name,tag:0b}
s = $ |
||
A compound data type that contains a reference to a single value, where the value can be of any data type. The data type of the value referred to can be changed. |
10 |
POINTER |
p = PTR_NEW(0b) |
||
A compound data type that contains a reference to an instance of an IDL object class. Object instances can contain data of any type, but the data types allowed are defined by the object class and cannot be changed after creation. |
11 |
Class name or OBJREF (for null objects) |
o = OBJ_NEW('class') |
||
A compound data type that contains a reference to a collection of values. The individual values can be of any data type, and the data types and values can be changed. |
11 |
LIST |
l = LIST(1,2) |
||
Hash | A compound data type that contains a reference to a collection of key-value pairs. The key can be of any scalar type, and the value can be of any type. The data types and values can be changed. | 11 | HASH | h = HASH('Id', 1234) |
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 Accuracy and Floating Point Operations . For information on your machine’s precision, see MACHAR .