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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
c5313e8d
Commit
c5313e8d
authored
Nov 03, 2005
by
holyfoot@deer.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #14268 (Bad FLOAT->DECIMAL conversion)
parent
531b847f
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
446 additions
and
1 deletion
+446
-1
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+410
-0
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+35
-0
strings/decimal.c
strings/decimal.c
+1
-1
No files found.
mysql-test/r/type_newdecimal.result
View file @
c5313e8d
This diff is collapsed.
Click to expand it.
mysql-test/t/type_newdecimal.test
View file @
c5313e8d
...
...
@@ -1050,3 +1050,38 @@ select cast(@non_existing_user_var/2 as DECIMAL);
#
--
error
1427
create
table
t
(
d
decimal
(
0
,
10
));
#
# Bug #14268 (bad FLOAT->DECIMAL conversion)
#
CREATE
TABLE
t1
(
my_float
FLOAT
,
my_double
DOUBLE
,
my_varchar
VARCHAR
(
50
),
my_decimal
DECIMAL
(
65
,
30
)
);
SHOW
CREATE
TABLE
t1
;
let
$max_power
=
32
;
while
(
$max_power
)
{
eval
INSERT
INTO
t1
SET
my_float
=
1.175494345
e
-
$max_power
,
my_double
=
1.175494345
e
-
$max_power
,
my_varchar
=
'1.175494345e-$max_power'
;
dec
$max_power
;
}
SELECT
my_float
,
my_double
,
my_varchar
FROM
t1
;
SELECT
CAST
(
my_float
AS
DECIMAL
(
65
,
30
)),
my_float
FROM
t1
;
SELECT
CAST
(
my_double
AS
DECIMAL
(
65
,
30
)),
my_double
FROM
t1
;
SELECT
CAST
(
my_varchar
AS
DECIMAL
(
65
,
30
)),
my_varchar
FROM
t1
;
UPDATE
t1
SET
my_decimal
=
my_float
;
SELECT
my_decimal
,
my_float
FROM
t1
;
UPDATE
t1
SET
my_decimal
=
my_double
;
SELECT
my_decimal
,
my_double
FROM
t1
;
UPDATE
t1
SET
my_decimal
=
my_varchar
;
SELECT
my_decimal
,
my_varchar
FROM
t1
;
DROP
TABLE
t1
;
strings/decimal.c
View file @
c5313e8d
...
...
@@ -973,7 +973,7 @@ int double2decimal(double from, decimal_t *to)
{
/* TODO: fix it, when we'll have dtoa */
char
s
[
400
],
*
end
;
sprintf
(
s
,
"%
f
"
,
from
);
sprintf
(
s
,
"%
.16G
"
,
from
);
end
=
strend
(
s
);
return
string2decimal
(
s
,
to
,
&
end
);
}
...
...
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