Maximum Value of a REAL Column

Maximum Value of a REAL Column

Post by yongsi » Tue, 24 Jun 2003 15:04:32



I created a table with a single column of REAL type:

CREATE TABLE test.mytable (a REAL NOT NULL);

The SQL type REAL is a 32-bit floating point type. Using JDBC, I tried
to insert the maximum value of a 32-bit floating point number, which
is Float.MAX_VALUE, into this table:

PreparedStatement ps = connection.prepareStatement("insert into
test.mytable (a) values (?)");
ps.setFloat(1, Float.MAX_VALUE);
ps.executeUpdate();

However, it failed with the following exception:

COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0302N  The
value of
a host variable in the EXECUTE or OPEN statement is too large for its
correspond
ing use.  SQLSTATE=22003

So it seems that the maximum value that a REAL column can store is
less than Float.MAX_VALUE. What is the maximum value then?

Thanks in advance.

Yong Sing

 
 
 

Maximum Value of a REAL Column

Post by Knut Stolz » Tue, 24 Jun 2003 15:49:58


yongsing wrote on Monday 23 June 2003 08:04:

Quote:> I created a table with a single column of REAL type:

> CREATE TABLE test.mytable (a REAL NOT NULL);

> The SQL type REAL is a 32-bit floating point type. Using JDBC, I tried
> to insert the maximum value of a 32-bit floating point number, which
> is Float.MAX_VALUE, into this table:

> PreparedStatement ps = connection.prepareStatement("insert into
> test.mytable (a) values (?)");
> ps.setFloat(1, Float.MAX_VALUE);
> ps.executeUpdate();

> However, it failed with the following exception:

> COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0302N  The
> value of
> a host variable in the EXECUTE or OPEN statement is too large for its
> correspond
> ing use.  SQLSTATE=22003

> So it seems that the maximum value that a REAL column can store is
> less than Float.MAX_VALUE. What is the maximum value then?

From the SQL Reference, Appendix A, "SQL Limits":

Smallest REAL value             -3.402E+38
Largest REAL value              +3.402E+38
Smallest positive REAL value    +1.175E-37
Largest negative REAL value     -1.175E-37

--
Knut Stolze
Information Integration
IBM Germany / University of Jena

 
 
 

Maximum Value of a REAL Column

Post by yongsi » Tue, 24 Jun 2003 17:55:20


Quote:> From the SQL Reference, Appendix A, "SQL Limits":

> Smallest REAL value             -3.402E+38
> Largest REAL value              +3.402E+38
> Smallest positive REAL value    +1.175E-37
> Largest negative REAL value     -1.175E-37

Thanks for the information.

Yong Sing

 
 
 

1. multi-column btree index for real values

Folks,

Can someone quickly describe how the btree is implemented for multiple
columns?  In particular, under what (if any) circumstances is there an
advantage if the index is over floating point values?

Thanks!

--Martin

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

2. SQL and SBS

3. Retrieving multiple columns where value is maximum

4. Crosstab query sorting

5. Getting maximum character values in a populated column

6. JDBC Driver for Paradox

7. Finding maximum value of a column ?

8. Real STUPID VB questions :(~

9. Copy Datetime Values from one Column to another before 2nd Columns values

10. SELECTing columns based on maximum in another column

11. Columns problem or a maximum number of column ?

12. use a value in a column to copy another value

13. Stored procedure returning variable value, not column value?