I have a class representing specific database table. Some the properties in this class as well as some of the fields in database table are type double.
Here, in the class, you see some properties have 1 significant digit eg. T12, T13, T18, T19 (0.8, 12.1 etc).
However when I execute insertion of this class into database table, Linq2Db
produces such a query:
When I look into database table, fields contains proper one-significant-digit values:
I know perfectly how floating point numbers are represented in binary format. I've already read article Why Are Floating Point Numbers Inaccurate?.
My questions:
Why double type repesentation in class (T12 = -0.8) differs from representation after 'Linq2Db' manipulates it (T12 = -0.800...004)?
Is it safe to save such double values in database? (I would like to prevent from having inaccurate values)
Why is there a difference between values in query and values in database table?
Edit 1:
This is a result of query on database. 15 significant digits (all 0's) vs 17 significant digits (screen above). Access can't show more than 15 digits.
Edit 2:
Decimal 0.8
Class Double 0.8
Floating-Point Double 0.8000000000000000444089209850062616169452667236328125
Floating-Point Single 0.800000011920928955078125 (for comparison)
SQL Query 0.80000000000000004 (!) => 17 digits after point (why?)
MS Access 0.800000000000000 = 0.8 => 15 digits after point
Why double type in class can be 0.8 but the same value without any manipulations or arithmetic operations is inserted into database as 0.80000000000000004? What 'Linq2Db' does with it?