Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7639e5af
Commit
7639e5af
authored
Jan 13, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge jwinstead2@wwwtst1.mysql.com:mysql-4.1-7774
into mysql.com:/home/jimw/my/mysql-4.1-clean
parents
8474953c
0a3fba7f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
3 deletions
+50
-3
mysql-test/r/type_float.result
mysql-test/r/type_float.result
+15
-0
mysql-test/r/type_float.result.es
mysql-test/r/type_float.result.es
+15
-0
mysql-test/t/type_float.test
mysql-test/t/type_float.test
+10
-0
sql/field.cc
sql/field.cc
+10
-3
No files found.
mysql-test/r/type_float.result
View file @
7639e5af
...
...
@@ -179,3 +179,18 @@ f
9.999
9.999
drop table if exists t1;
create table t1 (c char(20));
insert into t1 values (5e-28);
select * from t1;
c
5e-28
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
c
200000
2e+06
0.0002
2e-05
drop table t1;
mysql-test/r/type_float.result.es
View file @
7639e5af
...
...
@@ -179,3 +179,18 @@ f
9.999
9.999
drop table if exists t1;
create table t1 (c char(20));
insert into t1 values (5e-28);
select * from t1;
c
5e-28
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
c
200000
2e+06
0.0002
2e-05
drop table t1;
mysql-test/t/type_float.test
View file @
7639e5af
...
...
@@ -103,3 +103,13 @@ create table t1 (f double(4,3));
insert
into
t1
values
(
-
11.0
),(
-
11
),(
"-11"
),(
11.0
),(
11
),(
"11"
);
select
*
from
t1
;
drop
table
if
exists
t1
;
# Check conversion of floats to character field (Bug #7774)
create
table
t1
(
c
char
(
20
));
insert
into
t1
values
(
5
e
-
28
);
select
*
from
t1
;
drop
table
t1
;
create
table
t1
(
c
char
(
6
));
insert
into
t1
values
(
2
e5
),(
2
e6
),(
2
e
-
4
),(
2
e
-
5
);
select
*
from
t1
;
drop
table
t1
;
sql/field.cc
View file @
7639e5af
...
...
@@ -4301,13 +4301,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
));
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment