File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- lastmod : 2019-06-30
2
+ lastmod : 2020-02-08
3
3
date : 2016-10-16
4
4
menu :
5
5
main :
@@ -26,6 +26,24 @@ use `TINYINT` (or `TINYINT UNSIGNED`). The `(1)` suffix simply indicates the "di
26
26
(which is typically ignored by .NET programs), not the number of bytes used for storage. (And
27
27
for a ` bool ` C# value, use ` BOOL ` in SQL.)
28
28
29
+ ## Avoid FLOAT
30
+
31
+ MySQL stores ` FLOAT ` values as 32-bit single-precision IEEE 754 values. However, when returning
32
+ these values to a client application, "MySQL uses the ` FLT_DIG ` constant (which equals to 6 with
33
+ IEEE 754 encoding) to print float-type numbers". This can lead to an apparent loss of precision in
34
+ the least-significant digit when selecting values (even though they're stored with full precision).
35
+
36
+ Do not use a ` FLOAT ` column if your application needs to retrieve the exact same values that were
37
+ stored (with no loss of precision). You can instead use the ` DOUBLE ` column type (although it has
38
+ double the storage requirements), perform a calculation on the value (e.g., ` SELECT value+0 ` )
39
+ to coerce it to double-precison (using the original ` float ` value), or use a prepared statement
40
+ (i.e., ` MySqlCommand.Prepare ` ) which uses a binary protocol to retrieve the original value.
41
+
42
+ References:
43
+
44
+ * [ MySQL bug 87794] ( https://bugs.mysql.com/bug.php?id=87794 )
45
+ * [ StackOverflow answer] ( https://stackoverflow.com/a/60084985/23633 )
46
+
29
47
## Asynchronous Operation
30
48
31
49
MySqlConnector is fully asynchronous, supporting the async ADO.NET methods added in .NET 4.5 without blocking
You can’t perform that action at this time.
0 commit comments