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
835cf0f1
Commit
835cf0f1
authored
Dec 03, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more decimail bugs fixed
parent
3328c655
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
strings/decimal.c
strings/decimal.c
+24
-14
No files found.
strings/decimal.c
View file @
835cf0f1
...
@@ -585,7 +585,7 @@ int decimal2bin(decimal *from, char *to, int precision, int frac)
...
@@ -585,7 +585,7 @@ int decimal2bin(decimal *from, char *to, int precision, int frac)
{
{
dec1
mask
=
from
->
sign
?
-
1
:
0
,
*
buf1
=
from
->
buf
,
*
stop1
;
dec1
mask
=
from
->
sign
?
-
1
:
0
,
*
buf1
=
from
->
buf
,
*
stop1
;
int
error
=
E_DEC_OK
,
intg
=
precision
-
frac
,
int
error
=
E_DEC_OK
,
intg
=
precision
-
frac
,
isize1
,
intg1
,
intg1x
=
from
->
intg
,
isize1
,
intg1
,
intg1x
,
from_intg
=
from
->
intg
,
intg0
=
intg
/
DIG_PER_DEC1
,
intg0
=
intg
/
DIG_PER_DEC1
,
frac0
=
frac
/
DIG_PER_DEC1
,
frac0
=
frac
/
DIG_PER_DEC1
,
intg0x
=
intg
-
intg0
*
DIG_PER_DEC1
,
intg0x
=
intg
-
intg0
*
DIG_PER_DEC1
,
...
@@ -597,33 +597,33 @@ int decimal2bin(decimal *from, char *to, int precision, int frac)
...
@@ -597,33 +597,33 @@ int decimal2bin(decimal *from, char *to, int precision, int frac)
fsize1
=
frac1
*
sizeof
(
dec1
)
+
dig2bytes
[
frac1x
];
fsize1
=
frac1
*
sizeof
(
dec1
)
+
dig2bytes
[
frac1x
];
/* removing leading zeroes */
/* removing leading zeroes */
intg1
=
((
intg1x
-
1
)
%
DIG_PER_DEC1
)
+
1
;
intg1
=
((
from_intg
-
1
)
%
DIG_PER_DEC1
)
+
1
;
while
(
intg1x
>
0
&&
*
buf1
==
0
)
while
(
from_intg
>
0
&&
*
buf1
==
0
)
{
{
intg1x
-=
intg1
;
from_intg
-=
intg1
;
intg1
=
DIG_PER_DEC1
;
intg1
=
DIG_PER_DEC1
;
buf1
++
;
buf1
++
;
}
}
if
(
intg1x
>
0
)
if
(
from_intg
>
0
)
{
{
for
(
intg1
=
(
intg1x
-
1
)
%
DIG_PER_DEC1
;
*
buf1
<
powers10
[
intg1
--
];
intg1x
--
)
;
for
(
intg1
=
(
from_intg
-
1
)
%
DIG_PER_DEC1
;
*
buf1
<
powers10
[
intg1
--
];
from_intg
--
)
;
DBUG_ASSERT
(
intg1x
>
0
);
DBUG_ASSERT
(
from_intg
>
0
);
}
}
else
else
intg1x
=
0
;
from_intg
=
0
;
if
(
unlikely
(
intg1x
+
fsize1
==
0
))
if
(
unlikely
(
from_intg
+
fsize1
==
0
))
{
{
mask
=
0
;
/* just in case */
mask
=
0
;
/* just in case */
intg
=
1
;
intg
=
1
;
buf1
=&
mask
;
buf1
=&
mask
;
}
}
intg1
=
intg1x
/
DIG_PER_DEC1
;
intg1
=
from_intg
/
DIG_PER_DEC1
;
intg1x
=
intg1x
-
intg1
*
DIG_PER_DEC1
;
intg1x
=
from_intg
-
intg1
*
DIG_PER_DEC1
;
isize1
=
intg1
*
sizeof
(
dec1
)
+
dig2bytes
[
intg1x
];
isize1
=
intg1
*
sizeof
(
dec1
)
+
dig2bytes
[
intg1x
];
if
(
i
size0
<
isize1
)
if
(
i
ntg
<
from_intg
)
{
{
buf1
+=
intg1
-
intg0
+
(
intg1x
>
0
)
-
(
intg0x
>
0
);
buf1
+=
intg1
-
intg0
+
(
intg1x
>
0
)
-
(
intg0x
>
0
);
intg1
=
intg0
;
intg1x
=
intg0x
;
intg1
=
intg0
;
intg1x
=
intg0x
;
...
@@ -873,7 +873,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
...
@@ -873,7 +873,7 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
error
=
E_DEC_TRUNCATED
;
error
=
E_DEC_TRUNCATED
;
}
}
if
(
scale
+
from
->
intg
<
=
0
)
if
(
scale
+
from
->
intg
<
0
)
{
{
decimal_make_zero
(
to
);
decimal_make_zero
(
to
);
return
E_DEC_OK
;
return
E_DEC_OK
;
...
@@ -944,6 +944,16 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
...
@@ -944,6 +944,16 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
to
->
intg
++
;
to
->
intg
++
;
}
}
}
}
else
{
while
(
unlikely
(
*
buf1
==
0
)
&&
buf1
>=
to
->
buf
)
buf1
--
;
if
(
buf1
<
to
->
buf
)
{
decimal_make_zero
(
to
);
return
E_DEC_OK
;
}
}
if
(
scale
<
0
)
scale
=
0
;
if
(
scale
<
0
)
scale
=
0
;
done:
done:
...
@@ -2028,6 +2038,7 @@ main()
...
@@ -2028,6 +2038,7 @@ main()
test_d2b2d
(
".12345000098765"
,
30
,
20
);
test_d2b2d
(
".12345000098765"
,
30
,
20
);
test_d2b2d
(
"-.000000012345000098765"
,
30
,
20
);
test_d2b2d
(
"-.000000012345000098765"
,
30
,
20
);
test_d2b2d
(
"1234500009876.5"
,
30
,
5
);
test_d2b2d
(
"1234500009876.5"
,
30
,
5
);
test_d2b2d
(
"111111111.11"
,
10
,
2
);
printf
(
"==== decimal_cmp ====
\n
"
);
printf
(
"==== decimal_cmp ====
\n
"
);
test_dc
(
"12"
,
"13"
);
test_dc
(
"12"
,
"13"
);
...
@@ -2076,7 +2087,6 @@ main()
...
@@ -2076,7 +2087,6 @@ main()
test_ro
(
"999999999999999999999.999"
,
0
,
CEILING
);
test_ro
(
"999999999999999999999.999"
,
0
,
CEILING
);
test_ro
(
"-999999999999999999999.999"
,
0
,
FLOOR
);
test_ro
(
"-999999999999999999999.999"
,
0
,
FLOOR
);
return
0
;
return
0
;
}
}
#endif
#endif
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