0

I ran into an issue where it seems that mysql 5.1.63 (on a debian) stores 2/3 as
0.666666666666667 and on mysql 5.5.21 (on a mac) as
0.6666666666666667

as I happen to use Ebean to manage my database interactions, I need the mysql DOUBLE representation to correspond to the java double representation. (Otherwise Ebean will throw an OptimisticLockException as the java double representation can't be found in the mysql table)

As Ebean is generating the create table syntax for me and generates DOUBLE fields (no DECIMALs unfortunately), I was curious whether there is some setting to tell mysql which precision to use when a DOUBLE is defined without an explicit precision setting.

If you have other hints as to how resolve this issue, they are more than welcome as well.

Cheers, Daniel

Daniel
  • 2,642
  • 1
  • 26
  • 28
  • Actually it doesn't store either `0.666666666666667` or `0.666666666666667` because `DOUBLE` is a binary floating point type, and neither of those values can be represented exactly as a double. – Mark Byers Aug 02 '12 at 14:48
  • sorry for being imprecise here. "store" should probably say "represent", as those are the values that the mysql console displays after a SELECT query. Anyhow, I assume that those differing representations indicate a different precision, right? – Daniel Aug 02 '12 at 15:28

0 Answers0