mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge jwinstead2@wwwtst1.mysql.com:mysql-4.1-7774
into mysql.com:/home/jimw/my/mysql-5.0-clean
This commit is contained in:
13
sql/field.cc
13
sql/field.cc
@ -4390,13 +4390,20 @@ int Field_str::store(double nr)
|
||||
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||
uint length;
|
||||
bool use_scientific_notation= TRUE;
|
||||
use_scientific_notation= TRUE;
|
||||
if (field_length < 32 && fabs(nr) < log_10[field_length]-1)
|
||||
/*
|
||||
Check fabs(nr) against longest value that can be stored in field,
|
||||
which depends on whether the value is < 1 or not, and negative or not
|
||||
*/
|
||||
double anr= fabs(nr);
|
||||
int neg= (nr < 0.0) ? 1 : 0;
|
||||
if (field_length > 4 && field_length < 32 &&
|
||||
(anr < 1.0 ? anr > 1/(log_10[max(0,field_length-neg-2)]) /* -2 for "0." */
|
||||
: anr < log_10[field_length-neg]-1))
|
||||
use_scientific_notation= FALSE;
|
||||
|
||||
length= (uint) my_sprintf(buff, (buff, "%-.*g",
|
||||
(use_scientific_notation ?
|
||||
max(0, (int)field_length-5) :
|
||||
max(0, (int)field_length-neg-5) :
|
||||
field_length),
|
||||
nr));
|
||||
/*
|
||||
|
Reference in New Issue
Block a user