Hello,
 I'm losing precision when I send a double to a mysql database from a Java
 program trough JDBC.
 Code:
 stmt.setDouble(i+3,((Double)value).doubleValue());
 
 I use a prepared statement.
 Now, if I print out the double in java before sending it to the MySql
 database this is what it looks like:
 1277.00143924408
 (11 decimal digits)
 
 When I look in the database, this is what the value looks like:
 1277.00143924
 (8 decimal digits)
 
 The type of the column is "double"(without any precision or digits
 specification).
 
 Now the big question is: what happened to the last 3 decimal digits?
 Or is this just a display problem? Does the database only display 8
 decimal digits by default?
 So I changed the type in the table to "double(40,20)" and now the
 value in the database changes to:
 
 1277.00143924000008155417
 (exactly 20 decimal digits)
 
 Ok, next I set the type to "double(40,11)" and I get:
 1277.00143924000
 (11 decimal digits).
 
 Anyway, I lose the last digits. WHY? I thought that the MySql double
 type has the same precision than the java double type? Whats wrong
 here?
 
 Thanks for any answers...
 
 



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to