5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : The Long Float Storage Format
 
Share this page                  
The Long Float Storage Format
Ingres requires that the storage representation for long floating-point variables be d_float, because the EQUEL runtime system uses that format for floating-point conversions. If your EQUEL program has long_float variables that interact with the EQUEL 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. You can use three methods 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 );
...
## dbl: long_float;
Note that the pragma statement is not an EQUEL 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 EQUEL floating-point variables must be of the d_float type and format. For example:
## d_dbl: d_float;
   g_dbl: g_float; -- Unknown to EQUEL
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.