List:Internals« Previous MessageNext Message »
From:Roland Date:November 29 2001 6:05pm
Subject:Format of doubles in queries(feature request)
View as plain text  
Hello,
SKIP TO THE END IF YOU JUST WANT TO READ THE FEATURE REQUEST.

As a Java programmer, I often access a MySQL database trough a driver, and 
notice a little problem:
The MySQL format for DOUBLEs with exponent is like  3.41E+7
The '+' is required for positive exponents. If you wrote that same number 
as 3.41E7 it would generate a
syntax error.
The problem arises, when you convert a java double to string, the plus sign 
is omitted for positive exponents.
That means that java would output the above number as 3.41E7. When I pass 
this number on to a MySQL query I
get a syntax error. To avoid it I have two options:
1. (Easy) Enclose the double with single quotes. Works fine!
select * from  table where number='3.41E7';  instead of
select * from  table where number=3.41E7;
2. (Hard)  Change the format of the number to make Java convert it to 3.41E+7.

To make it all simpler why not:

FEATURE REQUEST:
Allow an alternate syntax for double types. When the exponent is positive 
the plus sign may be omitted. That means
3.41E+7 == 3.41E7.
Would that be too hard to implement? I don't think so. But it would save 
other programmers a lot of work. The way it is now,
each application programmer has to program his own conversion, or use the 
single-quotes trick.

Thanks for your attention,
Roland


Thread
Format of doubles in queries(feature request)Roland29 Nov
  • Re: Format of doubles in queries(feature request)Sinisa Milivojevic30 Nov
  • Format of doubles in queries(feature request)Michael Widenius30 Nov
  • Re: Format of doubles in queries(feature request)Roland30 Nov