Packing Codes for Numeric Data

The Uniface Numeric and Float data types are associated with many packing codes.

The following tables show the default packing codes for numeric data types, and the complete list of all packing codes for numeric data. Any of the packing codes might be converted to a more optimum storage format by the DBMS connector interface. For more information, see the relevant connector documentation.

Default Packing Codes for Numeric Data Types

Uniface data type

Default packing code

Float

F

Numeric

F

Numeric Packing Codes

Uniface Packing Code

Explanation

Uniface Data Types

Scaling Allowed

Numeric

Float

C (C20), C1-C32

Number, stored sign left, right-aligned, decimal point included, to a maximum of 9 decimal places

Y

Y

Y

F

F is mapped to a default of C20

Y

Y

Y

F4

Single precision F-float

Y

Y

Y

F8

Double-precision D-float

Y

Y

Y

G8

VMS private G-format

Y

Y

 

H4

IEEE 4-byte float

Y

Y

Y

H8

IEEE 8-byte float

Y

Y

Y

I(12)

Integer

Y

 

Y

I1

1-byte integer

Y

 

Y

I2

2-byte integer

Y

 

Y

I3

3-byte integer

Y

 

Y

I4

4-byte integer

Y

 

Y

I8

8-byte integer

Y

 

Y

I16

16-byte integer

Y

 

Y

M1

Money: 8-byte integer

Y

  Implicit

M2

Money: double-precision floating point storage

Y

  Implicit

M4

Sybase internal money data type

Y

  Implicit

M6

Sybase small money format

Y

  Implicit

N (N20), N1-N32

Number, stored without decimal point

Y

  Y

O (O20), O1-O32

Zoned numeric encoding of OpenVMS VAX trailing numeric

Y

   

P (P4), P1-P8

Packed decimal, +/- at beginning of field

Y

 

Y

Q (Q4), Q1-Q8

Packed decimal, +/- at end of field

Y

 

Y

Y1-Y32

User-defined packing code

Y

   

Null Values

When data is stored in a DBMS that does not support NULL values, it is not possible to tell the difference between a value of zero and empty (NULL) in numeric fields with packing codes I, F, P, and Q. Generally, record level DBMSs do not support NULL values. If a field with one of these packing codes explicitly receives a value of 0, Uniface displays it as if the field were empty.

Scaling

If scaling is defined for the packing codes I, F, P, and Q, this is not recognized by the DBMS. The scaling determines a default field layout and how Uniface handles the data. Other software does not understand scaling with data packed in this way unless explicitly programmed to do so.

For example, a field that has been defined as data type Numeric with a packing code of I4.2 (a 4-byte integer with two digits right of the decimal point) could accept a value of 123.45 within Uniface. The data would actually be stored as 12345; only Uniface would know where the decimal point should be.

Uniface Precision—data type Numeric

The I, P, and Q packing codes are internally equal to Uniface floating point precision, that is, a platform-independent precision of 38 digits for the mantissa, plus one for rounding, and four digits for the exponent, as follows:

+/- (99,999,999,999,999,999,999,999,999,999,999,999,999e+/- 9999)

The N and O packing codes are represented internally as a number of digits, of which the maximum is 32, not 38. Therefore, if you want greater precision than 32 digits, you should select an I, P, or Q packing code. When storing data, it depends on the DBMS whether this high precision is supported.

Uniface Precision—data type Float

For the data type Float, Uniface internally supports a platform- independent precision of 38 digits for the mantissa, plus one for rounding, and four digits for the exponent, as follows:

+/- (99,999,999,999,999,999,999,999,999,999,999,999,999e+/- 9999)

When storing data, it depends on the DBMS whether this high precision is supported.

User-Defined Packing Codes

You can define your own packing codes for Numeric fields. To do this, you must define the 3GL format conversion routines required by Uniface.