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 (Using IDL) 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. Type codes shown in the Description column correspond to the type code returned by the SIZE function for that data type.

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.

IDL type code: 1

a = 5B 

a = BYTE(5) 

BYTE

BYTARR

Integer

A 16-bit signed integer ranging from -32,768 to +32,767.

IDL type code: 2

b = 0 

b = 0S 

b = FIX(0) 

FIX

INTARR

Unsigned Integer

A 16-bit unsigned integer ranging from 0 to 65535.

IDL type code: 12

c = 0U 

c = UINT(0) 

UINT

UINTARR

Long

A 32-bit signed integer ranging in value from approximately minus two billion to plus two billion.

IDL type code: 3

d = 0L 

d = LONG(0) 

LONG

LONARR

Unsigned Long

A 32-bit unsigned integer ranging in value from 0 to approximately four billion.

IDL type code: 13

e = 0UL 

e = ULONG(0) 

ULONG

ULONARR

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.

IDL type code: 14

f = 0LL 

f = LONG64(0) 

LONG64

LON64ARR

64-bit Unsigned Long

A 64-bit unsigned integer ranging in value from 0 to 18,446,744,073,709,551,615.

IDL type code: 15

g = 0ULL 

g = ULONG64(0) 

ULONG64

ULON64ARR

Floating-point

A 32-bit, single-precision, floating-point number in the range of ±1038, with approximately six or seven decimal places of significance.

IDL type code: 4

h = 0.0 

h = FLOAT(0) 

FLOAT

FLTARR

Double-precision

A 64-bit, double-precision, floating-point number in the range of ±10308 with approximately 14 decimal places of significance.

IDL type code: 5

i = 0.0D 

i = DOUBLE(0) 

DOUBLE

DBLARR

Complex

A real-imaginary pair of single-precision, floating-point numbers. Complex numbers are useful for signal processing and frequency domain filtering.

IDL type code: 6

j = $
COMPLEX(1.0, 0.0) 

j = COMPLEX(1,0) 

COMPLEX

COMPLEXARR

Double-precision complex

A real-imaginary pair of double-precision, floating-point numbers.

IDL type code: 9

k = $
DCOMPLEX(1.0, 0.0) 

DCOMPLEX

DCOMPLEXARR

String

A sequence of characters, from 0 to 2147483647 (2.1 GB) characters in length, which is interpreted as text.

IDL type code: 7

l = 'Hello' 

l = $
STRING([72B, 101B, $ 
108B, 108B, 111B]) 

STRING

STRARR

Note
In 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 (Using IDL). For information on your machine's precision, see "MACHAR" (IDL Reference Guide).

Complex Data Types