FLOAT column does not hold 8-byte IEEE 754 float point value
Hi, It appears FLOAT(53) column does not hold IEEE-754 format float point value. Here is the document: https://my.vertica.com/docs/6.1.x/HTML/index.htm#2587.htm Here is my test: dbadmin=> create table test (col1 FLOAT(53)); CREATE TABLE dbadmin=> insert into test values('26906.44048159372'); OUTPUT -------- 1 (1 row) dbadmin=> select * from test; col1 ------------------ 26906.4404815937 <== I expect to see 26906.44048159372 here (1 row) Is this a bug or am I missing anything? Any help is appreciated. Thanks, Stone
0
Comments
import java.sql.*; import java.util.HashMap; import java.util.Map; import java.util.Properties; public class JDBCTest { public static void main(String[] args) throws Exception { main1("com.vertica.jdbc.Driver", "dbadmin", "", "jdbc:vertica://BELUS0891.apptio.lan:5433/biit", "demo_apptio_com.mytest"); main1("com.mysql.jdbc.Driver", "szhong", "", "jdbc:mysql://BELUS0891.apptio.lan:3306/test", "mytest"); } public static void main1(String driver, String username, String password, String url, String tableName) throws Exception { System.out.printf("Dirver = [%s]\n", driver); Class.forName( driver ); Properties connProp = new Properties(); connProp.put( "user", username); connProp.put( "password", password); Connection conn = DriverManager.getConnection(url, connProp); conn.setAutoCommit(true); Statement stmt = conn.createStatement(); try { stmt.execute("DROP TABLE " + tableName); } catch (SQLException e) { System.out.printf("%s\n", e.getMessage()); } stmt.close(); stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName + " (col1 FLOAT(53))"); stmt.close(); Double v1 = 26906.44048159372; System.out.printf("Value to insert, value = %.16f\n", v1); PreparedStatement stmt2 = conn.prepareStatement("INSERT INTO " + tableName + " VALUES(?)"); stmt2.setDouble(1, v1); stmt2.execute(); stmt2.close(); PreparedStatement stmt3 = conn.prepareStatement("SELECT col1 FROM " + tableName); ResultSet rs = stmt3.executeQuery(); rs.next(); Double v2 = rs.getDouble(1); rs.close(); stmt3.close(); System.out.printf("Value retrived, value = %.16f\n", v2); System.out.printf("Test %s\n", (v1.compareTo(v2) == 0)?"passed":"failed"); conn.close(); } }