Using Library Functions with a Packed Decimal Data Type - IBM-ILE

You can use the va_arg macro to accept a packed decimal data of the form (n,p).You can write packed decimal constants to a file, and scan them back.

Examples

The following example shows you how to use the va_arg macro to accept a packed decimal data of the form decimal(n,p). The va_arg macro returns the current packed decimal argument.

ILE C Source to Use the va_arg Macro with a Packed Decimal Data Type

ILE C Source to Use the va_arg Macro with a Packed Decimal Data Type

ILE C Source to Use the va_arg Macro with a Packed Decimal Data Type

The output is as follows:

output

The following example shows you how to write packed decimal constants to a file, and how to scan them back. In addition, the example shows you how to pass a packed decimal array to a function

ILE C Source to Write Packed Decimal Constants to a File and Scan Them Back

ILE C Source to Write Packed Decimal Constants to a File and Scan Them Back

ILE C Source to Write Packed Decimal Constants to a File and Scan Them Back

ILE C Source to Write Packed Decimal Constants to a File and Scan Them Back

The output is as follows

output

The following example shows how to use the %D(*,*) specifier with the printf() function. If n and p of the variable to be printed do not match with the n and p in the conversion specifier %D(n,p), the behavior is undefined. Use the unary operators digitsof (expression) and precisionof (expression) in the argument list to replace the * in D(*,*) whenever the size of the resulting type of a packed decimal expression is not known.

ILE C Source to Print Packed Decimal Constants

ILE C Source to Print Packed Decimal Constants

The output is as follows:

output

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM-ILE Topics