Keysight VISA.NET Help
Printf Types

Printf Types

In a Printf format specifer, the type is the only required field and appears after all of the optional modifiers. The type determines whether the associated argument is formatted as a character, string, number, or array. In many cases, the meaning of the other modifiers is dependent on the type.

Type

Valid Value Argument Types

Format Corresponding Input Argument As

Characters and Strings

c

Char, String

A single ASCII character. If the corresponding parameter is a String variable, only the first character is formatted.

s

String

An ASCII string.

Integer Numbers (formatted as strings)

d, i, u

SByte, SByte[]

Int16, Int16[]

Int32, Int32[]

Int64, Int64[]

Byte, Byte[]

UInt16, UInt16[]

UInt32, UInt32[]

UInt64, UInt64[]

An integer formatted as an ASCII string.

Unsigned types are cast to Int64 and then formatted.  UInt64 numbers greater than Int64.MaxValue are formatted as negative numbers.

o

An unsigned integer formatted as an octal ASCII string. Signed integer values are treated as unsigned for formatting.

x

An unsigned integer formatted as a hexadecimal ASCII string.  Signed integer values are treated as unsigned for formatting.  Digits a-f are lowercase.  If there is a "0x" prefix, the x is also lowercase.

X

An unsigned integer formatted as a hexadecimal ASCII string.  Signed integer values are treated as unsigned for formatting.  Digits A-F are uppercase.  If there is a "0X" prefix, the X is also uppercase.

Real Numbers (formatted as strings)

f

Single, Single[]

Double, Double[]

A real number formatted as an ASCII string using arithmetic notation.

e

A real number formatted as an ASCII string using engineering notation. The 'e' that introduces the exponent is lowercase.

E

A real number formatted as an ASCII string using engineering notation. The 'E' that introduces the exponent is uppercase.

g

A real number formatted as an ASCII string using arithmetic or engineering notation, depending on the scale of the number. If engineering notation is used, the 'e' that introduces the exponent is lowercase.

G

A real number formatted as an ASCII string using arithmetic or engineering notation, depending on the scale of the number. If engineering notation is used, the 'E' that introduces the exponent is uppercase.

IEEE 488.2 Blocks

b

Byte[], SByte[]

Int16[], UInt16[]

Int32[], UInt32[]

Single[], Double[]

(Int64[], UInt64[] are not supported at this time)

An array of numbers formatted as an IEEE 488.2 definite length block. The sign is not specified. A size modifier must be specified to properly format the block.  The size modifier must match the type of the corresponding array argument.

B

An array of numbers formatted as an IEEE 488.2 indefinite length block. The sign is not specified. A size modifier must be specified to properly format the block.  The size modifier must match the type of the corresponding array argument.

Raw Binary Arrays

y

Byte[], SByte[]

Int16[], UInt16[]

Int32[], UInt32[]

Int64[], UInt64[]

An array of signed or unsigned integers formatted as a binary array.  The array may be specified as big endian or little endian.  A size modifier must be specified to properly format the array.  The size modifier must match the type of the corresponding array argument.

Byte order may be specified for raw binary arrays by using "!ol" (little endian) or "!ob" (big endian) immediately after the '%' character that introduces the specifier.  The default is big endian.

 

The following format types are not valid for VISA.NET Printf methods: 'a', 'A', 'C', 'n', 'p', 'S', 't', 'T'.

 

See Also

 

 


© Keysight Technologies 2015-2026