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
e64d290b
Commit
e64d290b
authored
Nov 02, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
different (hopefully, correct) fix for bin2decimal bug
tests added
parent
fd88351a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
strings/decimal.c
strings/decimal.c
+13
-11
No files found.
strings/decimal.c
View file @
e64d290b
...
@@ -113,7 +113,7 @@ typedef longlong dec2;
...
@@ -113,7 +113,7 @@ typedef longlong dec2;
#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
static
const
dec1
powers10
[
DIG_PER_DEC1
+
1
]
=
{
static
const
dec1
powers10
[
DIG_PER_DEC1
+
1
]
=
{
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
,
1000000000
};
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
,
1000000000
};
static
const
int
dig2bytes
[
DIG_PER_DEC1
+
1
]
=
{
0
,
1
,
1
,
2
,
2
,
3
,
3
,
3
,
4
,
4
};
static
const
int
dig2bytes
[
DIG_PER_DEC1
+
1
]
=
{
0
,
1
,
1
,
2
,
2
,
3
,
3
,
4
,
4
,
4
};
#define sanity(d) DBUG_ASSERT((d)->len >0 && ((d)->buf[0] | \
#define sanity(d) DBUG_ASSERT((d)->len >0 && ((d)->buf[0] | \
(d)->buf[(d)->len-1] | 1))
(d)->buf[(d)->len-1] | 1))
...
@@ -719,10 +719,10 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
...
@@ -719,10 +719,10 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
dec1
x
;
dec1
x
;
switch
(
i
)
switch
(
i
)
{
{
case
1
:
x
=
mi_
u
int1korr
(
from
);
break
;
case
1
:
x
=
mi_
s
int1korr
(
from
);
break
;
case
2
:
x
=
mi_
u
int2korr
(
from
);
break
;
case
2
:
x
=
mi_
s
int2korr
(
from
);
break
;
case
3
:
x
=
mi_
u
int3korr
(
from
);
break
;
case
3
:
x
=
mi_
s
int3korr
(
from
);
break
;
case
4
:
x
=
mi_
u
int4korr
(
from
);
break
;
case
4
:
x
=
mi_
s
int4korr
(
from
);
break
;
default:
DBUG_ASSERT
(
0
);
default:
DBUG_ASSERT
(
0
);
}
}
from
+=
i
;
from
+=
i
;
...
@@ -735,7 +735,7 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
...
@@ -735,7 +735,7 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
for
(
stop
=
from
+
intg0
*
sizeof
(
dec1
);
from
<
stop
;
from
+=
sizeof
(
dec1
))
for
(
stop
=
from
+
intg0
*
sizeof
(
dec1
);
from
<
stop
;
from
+=
sizeof
(
dec1
))
{
{
DBUG_ASSERT
(
sizeof
(
dec1
)
==
4
);
DBUG_ASSERT
(
sizeof
(
dec1
)
==
4
);
*
buf
=
mi_
u
int4korr
(
from
)
^
mask
;
*
buf
=
mi_
s
int4korr
(
from
)
^
mask
;
if
(
buf
>
to
->
buf
||
*
buf
!=
0
)
if
(
buf
>
to
->
buf
||
*
buf
!=
0
)
buf
++
;
buf
++
;
else
else
...
@@ -745,7 +745,7 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
...
@@ -745,7 +745,7 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
for
(
stop
=
from
+
frac0
*
sizeof
(
dec1
);
from
<
stop
;
from
+=
sizeof
(
dec1
))
for
(
stop
=
from
+
frac0
*
sizeof
(
dec1
);
from
<
stop
;
from
+=
sizeof
(
dec1
))
{
{
DBUG_ASSERT
(
sizeof
(
dec1
)
==
4
);
DBUG_ASSERT
(
sizeof
(
dec1
)
==
4
);
*
buf
=
mi_
u
int4korr
(
from
)
^
mask
;
*
buf
=
mi_
s
int4korr
(
from
)
^
mask
;
buf
++
;
buf
++
;
}
}
if
(
frac0x
)
if
(
frac0x
)
...
@@ -754,10 +754,10 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
...
@@ -754,10 +754,10 @@ int bin2decimal(char *from, decimal *to, int precision, int scale)
dec1
x
;
dec1
x
;
switch
(
i
)
switch
(
i
)
{
{
case
1
:
x
=
mi_
u
int1korr
(
from
);
break
;
case
1
:
x
=
mi_
s
int1korr
(
from
);
break
;
case
2
:
x
=
mi_
u
int2korr
(
from
);
break
;
case
2
:
x
=
mi_
s
int2korr
(
from
);
break
;
case
3
:
x
=
mi_
u
int3korr
(
from
);
break
;
case
3
:
x
=
mi_
s
int3korr
(
from
);
break
;
case
4
:
x
=
mi_
u
int4korr
(
from
);
break
;
case
4
:
x
=
mi_
s
int4korr
(
from
);
break
;
default:
DBUG_ASSERT
(
0
);
default:
DBUG_ASSERT
(
0
);
}
}
*
buf
=
(
x
^
mask
)
*
powers10
[
DIG_PER_DEC1
-
frac0x
];
*
buf
=
(
x
^
mask
)
*
powers10
[
DIG_PER_DEC1
-
frac0x
];
...
@@ -1986,6 +1986,8 @@ main()
...
@@ -1986,6 +1986,8 @@ main()
test_md
(
"234.567"
,
"-10.555"
);
test_md
(
"234.567"
,
"-10.555"
);
printf
(
"==== decimal2bin/bin2decimal ====
\n
"
);
printf
(
"==== decimal2bin/bin2decimal ====
\n
"
);
test_d2b2d
(
"-10.55"
,
4
,
2
);
test_d2b2d
(
"0.0123456789012345678912345"
,
30
,
25
);
test_d2b2d
(
"12345"
,
5
,
0
);
test_d2b2d
(
"12345"
,
5
,
0
);
test_d2b2d
(
"12345"
,
10
,
3
);
test_d2b2d
(
"12345"
,
10
,
3
);
test_d2b2d
(
"123.45"
,
10
,
3
);
test_d2b2d
(
"123.45"
,
10
,
3
);
...
...
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