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
bd10f962
Commit
bd10f962
authored
Oct 18, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arbitrary precision decimal numbers
parent
09e9651a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1714 additions
and
9 deletions
+1714
-9
.bzrignore
.bzrignore
+1
-0
include/decimal.h
include/decimal.h
+68
-0
strings/Makefile.am
strings/Makefile.am
+17
-8
strings/decimal.c
strings/decimal.c
+1627
-0
strings/llstr.c
strings/llstr.c
+1
-1
No files found.
.bzrignore
View file @
bd10f962
...
@@ -920,3 +920,4 @@ vio/test-ssl
...
@@ -920,3 +920,4 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslclient
vio/test-sslserver
vio/test-sslserver
vio/viotest-ssl
vio/viotest-ssl
strings/test_decimal
include/decimal.h
0 → 100644
View file @
bd10f962
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _decimal_h
#define _decimal_h
#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
/* for my_alloca */
typedef
enum
{
TRUNCATE
=
0
,
EVEN
}
dec_round_mode
;
typedef
uint32
decimal_digit
;
typedef
struct
st_decimal
{
int
intg
,
frac
,
len
;
my_bool
sign
;
decimal_digit
*
buf
;
}
decimal
;
int
decimal2string
(
decimal
*
from
,
char
*
to
,
uint
*
to_len
);
int
string2decimal
(
char
*
from
,
decimal
*
to
,
char
**
end
);
int
decimal2ulonglong
(
decimal
*
from
,
ulonglong
*
to
);
int
ulonglong2decimal
(
ulonglong
from
,
decimal
*
to
);
int
decimal2longlong
(
decimal
*
from
,
longlong
*
to
);
int
longlong2decimal
(
longlong
from
,
decimal
*
to
);
int
decimal2double
(
decimal
*
from
,
double
*
to
);
int
double2decimal
(
double
from
,
decimal
*
to
);
int
decimal_add
(
decimal
*
from1
,
decimal
*
from2
,
decimal
*
to
);
int
decimal_sub
(
decimal
*
from1
,
decimal
*
from2
,
decimal
*
to
);
int
decimal_mul
(
decimal
*
from1
,
decimal
*
from2
,
decimal
*
to
);
int
decimal_div
(
decimal
*
from1
,
decimal
*
from2
,
decimal
*
to
,
int
scale_incr
);
int
decimal_mod
(
decimal
*
from1
,
decimal
*
from2
,
decimal
*
to
);
int
decimal_result_size
(
decimal
*
from1
,
decimal
*
from2
,
char
op
,
int
param
);
int
decimal_round
(
decimal
*
dec
,
int
new_scale
,
dec_round_mode
mode
);
/*
conventions:
decimal_smth() == 0 -- everything's ok
decimal_smth() <= 0 -- result is usable, precision loss is possible
decimal_smth() <= 1 -- result is unusable, but most significant digits
can be lost
decimal_smth() > 1 -- no result was generated
*/
#define E_DEC_TRUNCATED -1
#define E_DEC_OK 0
#define E_DEC_OVERFLOW 1
#define E_DEC_DIV_ZERO 2
#define E_DEC_BAD_NUM 3
#define E_DEC_OOM 4
#endif
strings/Makefile.am
View file @
bd10f962
...
@@ -22,19 +22,19 @@ pkglib_LIBRARIES = libmystrings.a
...
@@ -22,19 +22,19 @@ pkglib_LIBRARIES = libmystrings.a
# Exact one of ASSEMBLER_X
# Exact one of ASSEMBLER_X
if
ASSEMBLER_x86
if
ASSEMBLER_x86
ASRCS
=
strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
ASRCS
=
strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
CSRCS
=
bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c ctype-extra.c
CSRCS
=
bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c
decimal.c
ctype-extra.c
else
else
if
ASSEMBLER_sparc32
if
ASSEMBLER_sparc32
# These file MUST all be on the same line!! Otherwise automake
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
# generats a very broken makefile
ASRCS
=
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
ASRCS
=
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
CSRCS
=
strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c ctype-extra.c my_strtoll10.c
CSRCS
=
strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c
decimal.c
ctype-extra.c my_strtoll10.c
else
else
#no assembler
#no assembler
ASRCS
=
ASRCS
=
# These file MUST all be on the same line!! Otherwise automake
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
# generats a very broken makefile
CSRCS
=
strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c ctype-extra.c my_strtoll10.c
CSRCS
=
strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c
decimal.c
ctype-extra.c my_strtoll10.c
endif
endif
endif
endif
...
@@ -43,9 +43,9 @@ noinst_PROGRAMS = conf_to_src
...
@@ -43,9 +43,9 @@ noinst_PROGRAMS = conf_to_src
DISTCLEANFILES
=
ctype_autoconf.c
DISTCLEANFILES
=
ctype_autoconf.c
# Default charset definitions
# Default charset definitions
EXTRA_DIST
=
ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-win1250ch.c
\
EXTRA_DIST
=
ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-win1250ch.c
\
ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c
\
ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c
\
ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c
\
ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c
\
xm
l.c strto.c strings-x86.s
\
xml.c decima
l.c strto.c strings-x86.s
\
longlong2str.c longlong2str-x86.s
\
longlong2str.c longlong2str-x86.s
\
my_strtoll10.c my_strtoll10-x86.s
\
my_strtoll10.c my_strtoll10-x86.s
\
strxmov.c bmove_upp.c strappend.c strcont.c strend.c
\
strxmov.c bmove_upp.c strappend.c strcont.c strend.c
\
...
@@ -54,7 +54,7 @@ EXTRA_DIST = ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-win1250ch.c \
...
@@ -54,7 +54,7 @@ EXTRA_DIST = ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-win1250ch.c \
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s
\
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s
\
strinstr-sparc.s strmake-sparc.s strmov-sparc.s
\
strinstr-sparc.s strmake-sparc.s strmov-sparc.s
\
strnmov-sparc.s strstr-sparc.s strxmov-sparc.s
\
strnmov-sparc.s strstr-sparc.s strxmov-sparc.s
\
t_ctype.h
t_ctype.h
libmystrings_a_LIBADD
=
libmystrings_a_LIBADD
=
conf_to_src_SOURCES
=
conf_to_src.c xml.c ctype.c
conf_to_src_SOURCES
=
conf_to_src.c xml.c ctype.c
...
@@ -73,8 +73,17 @@ if ASSEMBLER
...
@@ -73,8 +73,17 @@ if ASSEMBLER
$(AS)
$(ASFLAGS)
-o
$@
$<
$(AS)
$(ASFLAGS)
-o
$@
$<
endif
endif
FLAGS
=
$(DEFS)
$(INCLUDES)
$(CPPFLAGS)
$(CFLAGS)
@NOINST_LDFLAGS@
LIBS
=
libmystrings.a
str_test
:
str_test.c $(LIBRARIES)
str_test
:
str_test.c $(LIBRARIES)
$(LINK)
$(FLAGS)
-DMAIN
$INCLUDES
$(srcdir)
/str_test.c
$(LDADD)
$(LIBS)
$(pkglib_LIBRARIES)
$(LINK)
$(FLAGS)
-DMAIN
$(INCLUDES)
$(srcdir)
/str_test.c
$(LDADD)
$(LIBS)
$(pkglib_LIBRARIES)
test_decimal$(EXEEXT)
:
decimal.c $(LIBRARIES)
$(CP)
$(srcdir)
/decimal.c ./test_decimal.c
$(LINK)
$(FLAGS)
-DMAIN
./test_decimal.c
$(LDADD)
$(LIBS)
$(RM)
-f
./test_decimal.c
# Don't update the files from bitkeeper
# Don't update the files from bitkeeper
%
::
SCCS/s.%
%
::
SCCS/s.%
strings/decimal.c
0 → 100644
View file @
bd10f962
This diff is collapsed.
Click to expand it.
strings/llstr.c
View file @
bd10f962
...
@@ -30,6 +30,6 @@
...
@@ -30,6 +30,6 @@
char
*
llstr
(
longlong
value
,
char
*
buff
)
char
*
llstr
(
longlong
value
,
char
*
buff
)
{
{
longlong
2
str
(
value
,
buff
,
-
10
);
longlong
10_to_
str
(
value
,
buff
,
-
10
);
return
buff
;
return
buff
;
}
}
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