SQL/MX Programming Manual for Java

SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java523726-003
3-39
Floating-Point Data Types
Floating-Point Data Types
Like JDBC/MX and other Java programs, SQLJ programs handle all floating-point data
in IEEE floating-point format. SQL/MX statements embedded in an SQLJ program can
query both SQL/MX and SQL/MP format tables. Each type of table stores floating-point
data in a different format.
SQL/MX Floating-Point Format
In SQL/MX tables, floating-point values are stored in IEEE floating-point format.
Conversion of the floating-point format does not occur when an SQLJ program queries
floating-point values in SQL/MX tables.
SQL/MP Floating-Point Format
In SQL/MP tables, floating-point values are stored in Tandem floating-point format.
When an SQLJ program assigns a floating-point value from an SQL/MP column to a
Java host variable, SQL/MX converts the Tandem floating-point format to IEEE
floating-point format. Likewise, when an SQLJ program assigns a floating-point value
from a Java host variable to an SQL/MP column, SQL/MX converts the IEEE floating-
point format to Tandem floating-point format.
Conversion Between Tandem and IEEE Floating-Point Formats
When converting a Tandem floating-point data type to the corresponding IEEE data
type, all Tandem floating-point data types are converted to IEEE DOUBLE
representation. Despite this conversion, the precision of Tandem floating-point data
types are maintained correctly in IEEE floating-point format. A Tandem REAL or
FLOAT with precision between 1 and 22 cannot be converted to IEEE REAL because
the Tandem exponent will not fit in an IEEE REAL data type. Although no equivalent
exists for single-precision Tandem REAL and FLOAT in IEEE floating-point format, the
conversion to IEEE DOUBLE preserves the precision and the exponent.
If you want a small floating-point data type with a smaller exponent and less storage,
consider declaring the host variables as float or java.lang.Float. If you want a
larger exponent and more precision, consider declaring the host variables as double
or java.lang.Double.
For more information about floating-point data types, see the SQL/MX Reference
Manual, JDBC Driver for SQL/MX Programmer's Reference, and NonStop Server for
Java Programmer's Reference.