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
f1fb785b
Commit
f1fb785b
authored
Jun 15, 2005
by
hf@deer.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #10632 (CEILING returns wrong result)
parent
dd0936ca
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
mysql-test/r/func_math.result
mysql-test/r/func_math.result
+6
-0
mysql-test/t/func_math.test
mysql-test/t/func_math.test
+7
-0
strings/decimal.c
strings/decimal.c
+25
-4
No files found.
mysql-test/r/func_math.result
View file @
f1fb785b
...
@@ -146,3 +146,9 @@ drop table t1;
...
@@ -146,3 +146,9 @@ drop table t1;
select round(150, 2);
select round(150, 2);
round(150, 2)
round(150, 2)
150.00
150.00
select ceil(0.09);
ceil(0.09)
1
select ceil(0.000000000000000009);
ceil(0.000000000000000009)
1
mysql-test/t/func_math.test
View file @
f1fb785b
...
@@ -84,3 +84,10 @@ drop table t1;
...
@@ -84,3 +84,10 @@ drop table t1;
# Bug #10083 (round doesn't increase decimals)
# Bug #10083 (round doesn't increase decimals)
#
#
select
round
(
150
,
2
);
select
round
(
150
,
2
);
#
# Bug @10632 (Ceiling function returns wrong answer)
#
select
ceil
(
0.09
);
select
ceil
(
0.000000000000000009
);
strings/decimal.c
View file @
f1fb785b
...
@@ -1490,11 +1490,31 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
...
@@ -1490,11 +1490,31 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
buf1
+=
intg0
+
frac0
-
1
;
buf1
+=
intg0
+
frac0
-
1
;
if
(
scale
==
frac0
*
DIG_PER_DEC1
)
if
(
scale
==
frac0
*
DIG_PER_DEC1
)
{
{
int
do_inc
=
FALSE
;
DBUG_ASSERT
(
frac0
+
intg0
>=
0
);
DBUG_ASSERT
(
frac0
+
intg0
>=
0
);
x
=
buf0
[
1
]
/
DIG_MASK
;
switch
(
round_digit
)
if
(
x
>
round_digit
||
{
(
round_digit
==
5
&&
x
==
5
&&
(
mode
==
HALF_UP
||
case
0
:
(
frac0
+
intg0
>
0
&&
*
buf0
&
1
))))
{
dec1
*
p0
=
buf0
+
(
frac1
-
frac0
);
for
(;
p0
>
buf0
;
p0
--
)
if
(
*
p0
)
{
do_inc
=
TRUE
;
break
;
};
break
;
}
case
5
:
{
x
=
buf0
[
1
]
/
DIG_MASK
;
do_inc
=
(
x
>
5
)
||
((
x
==
5
)
&&
(
mode
==
HALF_UP
||
(
frac0
+
intg0
>
0
&&
*
buf0
&
1
)));
break
;
};
default:
;
};
if
(
do_inc
)
{
{
if
(
frac0
+
intg0
>
0
)
if
(
frac0
+
intg0
>
0
)
(
*
buf1
)
++
;
(
*
buf1
)
++
;
...
@@ -1509,6 +1529,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
...
@@ -1509,6 +1529,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
}
}
else
else
{
{
/* TODO - fix this code as it won't work for CEILING mode */
int
pos
=
frac0
*
DIG_PER_DEC1
-
scale
-
1
;
int
pos
=
frac0
*
DIG_PER_DEC1
-
scale
-
1
;
DBUG_ASSERT
(
frac0
+
intg0
>
0
);
DBUG_ASSERT
(
frac0
+
intg0
>
0
);
x
=*
buf1
/
powers10
[
pos
];
x
=*
buf1
/
powers10
[
pos
];
...
...
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