5. Embedded SQL for Ada : Ada Variables and Data Types : Embedded SQL/Ada Declarations : Long Float Storage Format
 
Share this page                  
Long Float Storage Format
Ingres requires that the storage representation for long floating-point variables be d_float, because the Embedded SQL runtime system uses that format for floating-point conversions. If your Embedded SQL program has long_float variables that interact with the Embedded SQL runtime system, you must make sure they are stored in the d_float format. Floating-point values of types g_float and h_float are stored in different formats and sizes. The default Ada format is g_float; consequently, you must convert your long floating-point variables to type d_float. There are three methods you can use to ensure that the Ada compiler always uses the d_float format.
The first method is to issue the following Ada pragma before every compilation unit that declares long_float variables:
pragma long_float( d_float );
exec sql begin declare section;
            dbl: long_float;
exec sql end declare section;
Note that the pragma statement is not an Embedded SQL statement, but an Ada statement that directs the compiler to use a different storage format for long_float variables.
The second method is a more general instance of the first. If you are certain that all long_float variables in your Ada program library will use the d_float format, including those not interacting with Ingres, then you can install the pragma into the program library by issuing the following ACS command:
acs set pragma/long_float=d_float
This system-level command is equivalent to issuing the Ada pragma statement for each file that uses long_float variables.
The third method is to use the type d_float instead of the type long_float. This has the advantage of allowing you to mix both d_float and g_float storage formats in the same compilation unit. Of course, all Embedded SQL floating-point variables must be of the d_float type and format. For example:
exec sql begin declare section;
        d_dbl: d_float;
exec sql end declare section;

        g_dbl: g_float; -- Unknown to Embedded SQL
One side effect of all the above conversions is that some default system package instantiations for the type long_float become invalid because they are set up under the g_float format. For example, the package long_float_text_io, which is used to write long floating-point values to text files, must be reinstantiated. Assuming that you have issued the following ACS command on your program library:
acs set pragma/long_float=d_float
you must reinstantiate the long_float_text_io package before you can use it. A typical file might contain the following two lines, which serve to enter your own copy of long_float_text_io into your library:
with text_io;
package long_float_text_io is new
             text_io.float_io(long_float);
A later statement, such as:
with long_float_text_io; use long_float_text_io;
will pick up your new copy of the package, which is defined using the d_float internal storage format.