B, I, O, and Z Format Codes

Available Format Codes

The B, I, O, and Z format codes are used to transfer integer values to and from the specified file. The B format code is used to output binary values, I is used for decimal values, O is used for octal values, and Z is used for hexadecimal values.

The syntax is:

[n]B[-][w][.m] 
[n]I[+][-][w][.m] 
[n]O[-][w][.m] 
[n]Z[-][w][.m] 

where the parameters "n", "+", and "-" are as described in Syntax of Format Codes and the width specification is as follows:

w

is an optional width specification (0 ≤ ≤ 255). The variable w specifies the number of digits to be transferred. See Padding and Natural Width Formatting for additional details on the output width of a formatted value.

m

is an optional minimum number (1 ≤ ≤ 255) of nonblank digits to be shown on output. The field is zero-filled on the left if necessary. If m is omitted or zero, the output is padded with blanks to achieve the specified width.

Note - The m parameter is ignored if w is zero.

Overflow

On output, if the field provided is not wide enough, it is filled with asterisks (*) to indicate the overflow condition.

Default Values of the w Parameter

The default values used by the I, O, and Z format codes if w is omitted are specified in the following table:

Table 18-8: Integer Format Defaults
(I, O, and Z format codes) 

Data Type
w

Byte, Int, UInt

7

Long, ULong, Float

12

Long64, ULong64

22

Double

23

All Other Types

12

The default values used by the B format code if w is omitted are specified in the following table:

Table 18-9: Integer Format Defaults
(B format code)

Data Type
w

Byte

8

Int, UInt

16

Long, ULong

32

Long64, ULong64

64

All Other Types

32

Format Code Examples

The following table shows the results of the application of various format codes to given data values. Note that normally, the case of the format code is ignored by IDL. However, the case of the Z format codes determines the case used to output the hexadecimal digits A-F.

Table 18-10: Integer Output Examples
("b" represents a blank space) 

Format
Internal Value
Formatted Output

B

3000

bbbb101110111000

B15

3000

bbb101110111000

B14.14

3000

00101110111000

I

3000

bbb3000

I6.5

3000

b03000

I5.6

3000

*****

I2

3000

**

O

3000

bbb5670

O6.5

3000

b05670

O5.6

3000

*****

O2

3000

**

z

3000

bbbbbb8

Z

3000

bbbbBB8

Z6.5

3000

b00BB8

Z5.6

3000

*****

Z2

3000

**