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
15e4414c
Commit
15e4414c
authored
Dec 06, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strings/decimal.c
handle test_ro(".999", 0, HALF_UP, "1");
parent
2db2cda3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
strings/decimal.c
strings/decimal.c
+14
-4
No files found.
strings/decimal.c
View file @
15e4414c
...
...
@@ -901,19 +901,26 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
if
(
scale
>=
from
->
frac
)
goto
done
;
/* nothing to do */
DBUG_ASSERT
(
frac0
+
intg0
>
0
);
buf0
+=
intg0
+
frac0
-
1
;
buf1
+=
intg0
+
frac0
-
1
;
if
(
scale
==
frac0
*
DIG_PER_DEC1
)
{
DBUG_ASSERT
(
frac0
+
intg0
>=
0
);
x
=
buf0
[
1
]
/
DIG_MASK
;
if
(
x
>
round_digit
||
(
round_digit
==
5
&&
x
==
5
&&
(
mode
==
HALF_UP
||
*
buf0
&
1
)))
(
*
buf1
)
++
;
(
round_digit
==
5
&&
x
==
5
&&
(
mode
==
HALF_UP
||
(
frac0
+
intg0
>
0
&&
*
buf0
&
1
))))
{
if
(
frac0
+
intg0
>
0
)
(
*
buf1
)
++
;
else
*
(
++
buf1
)
=
DIG_BASE
;
}
}
else
{
int
pos
=
frac0
*
DIG_PER_DEC1
-
scale
-
1
;
DBUG_ASSERT
(
frac0
+
intg0
>
0
);
x
=*
buf1
/
powers10
[
pos
];
y
=
x
%
10
;
if
(
y
>
round_digit
||
...
...
@@ -942,7 +949,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
scale
=
frac0
*
DIG_PER_DEC1
;
error
=
E_DEC_TRUNCATED
;
/* XXX */
}
for
(
buf1
=
to
->
buf
+
frac0
+
intg0
;
buf1
>
to
->
buf
;
buf1
--
)
for
(
buf1
=
to
->
buf
+
intg0
+
max
(
frac0
,
0
)
;
buf1
>
to
->
buf
;
buf1
--
)
{
buf1
[
0
]
=
buf1
[
-
1
];
}
...
...
@@ -2103,6 +2110,9 @@ main()
test_ro
(
"15.4"
,
-
1
,
HALF_UP
,
"20"
);
test_ro
(
"-15.4"
,
-
1
,
HALF_UP
,
"-20"
);
test_ro
(
"5.4"
,
-
1
,
HALF_UP
,
"10"
);
test_ro
(
".999"
,
0
,
HALF_UP
,
"1"
);
memset
(
buf2
,
33
,
sizeof
(
buf2
));
test_ro
(
"999999999"
,
-
9
,
HALF_UP
,
"1000000000"
);
test_ro
(
"15.1"
,
0
,
HALF_EVEN
,
"15"
);
test_ro
(
"15.5"
,
0
,
HALF_EVEN
,
"16"
);
test_ro
(
"14.5"
,
0
,
HALF_EVEN
,
"14"
);
...
...
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