Mysql version: 3.23.41 and 4.01
OS: NT4SP6a, W2KSP2

There is some inconsistency in how many significant digits mysql
displays/returns for double values.  For example, a value of
1.1790123350679011E22 is returned as 1.1790123350679e+022 (last 3 digits
rounded, only 14 significant digits).  However, if the function
round(col,17) is applied then the value is returned as
11790123350679011000000.00000000000000000 (which correctly contains all 17
significant digits), so the database must be preserving this accuracy
internally.  Unfortunately, this approach (using the round function) does
not work well for very small or very large numbers, as they really need to
be returned in scientific notation.

Is there a way to force mysql to return double values in scientific notation
with the highest possible number of significant digits (i.e. typically 16 or
17)?

Below is captured output from a mysql session demonstrating the above
example:

mysql> create table test1 (col1 double);
Query OK, 0 rows affected (0.04 sec)

mysql> insert into test1 values(1.1790123350679011E22);
Query OK, 1 row affected (0.01 sec)

mysql> select * from test1;
+----------------------+
| col1                 |
+----------------------+
| 1.1790123350679e+022 |
+----------------------+
1 row in set (0.00 sec)

mysql> select round(col1,17) from test1;
+-------------------------------------------+
| round(col1,17)                            |
+-------------------------------------------+
| 11790123350679011000000.00000000000000000 |
+-------------------------------------------+
1 row in set (0.01 sec)


Thanks in advance for any suggestions.

Scott Tindal
QA Specialist
Hummingbird
Kingston, Ontario


---------------------------------------------------------------------
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