SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
3-30
Numeric Data
You can choose to convert a GMP multi-precision value into the new BigNum external
format by using GMP low-level library routines mpz_import(). The following example
shows the usage of mpz_import()function:
// Convert 12345678901234567890 from GMP to Bignum
// external format.
//Declare the Bignum in GMP format
mpz_t z;
// Will contain the internal format.
NUMERIC(50,5) s; size_t count;
//initialize the bignum in GMP format
mpz_init_set_str(z, "12345678901234567890", 10);
// Convert the GMP format z to internal format s
mpz_export(s, // Output Bignum in internal format.
&count, // The number of chunks written to s.
-1, // Least significant chunk first.
2, // Size of each chunk, in bytes.
0, // Native endianness within the chunk.
0, // Nails. I do not know what this is.
z // Input Bignum in GMP format.
);
BigNum Format for TMFARLIB
The BigNum data type is displayed using a presentation type by TMFARLIB2. The
presentation type for a BigNum type value in TMFARLIB2 is specified by the following
Guardian DEFINE:
Add Define =_MX_ARLIB_BIGNUM_FORMAT, CLASS=MAP
FILE=\$dummy.dummy.value
value can be an ASCII or a BINARY value.
This is a MAP define. The node name, volume, and subvolume parts are ignored, only
the file name part of the DEFINE value is interpreted by SQL/MX. Valid values for the
filename part are as follows:
BINARY - The BigNum binary format is used as the presentation type. This is
default.
ASCII - The ASCII format is used as the presentation type.
For example, the DEFINE in the binary format is as follows: