summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index f6ac4717a32..7b4c8649ec3 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -991,12 +991,18 @@ int decimal2double(decimal_t *from, double *to)
int double2decimal(double from, decimal_t *to)
{
/* TODO: fix it, when we'll have dtoa */
- char s[400], *end;
- sprintf(s, "%.16G", from);
- end= strend(s);
- return string2decimal(s, to, &end);
+ char buff[400], *end;
+ int length, res;
+ DBUG_ENTER("double2decimal");
+ length= my_sprintf(buff, (buff, "%.16G", from));
+ DBUG_PRINT("info",("from: %g from_as_str: %s", from, buff));
+ end= buff+length;
+ res= string2decimal(buff, to, &end);
+ DBUG_PRINT("exit", ("res: %d", res));
+ DBUG_RETURN(res);
}
+
static int ull2dec(ulonglong from, decimal_t *to)
{
int intg1, error=E_DEC_OK;
@@ -1908,6 +1914,14 @@ static int do_sub(decimal_t *from1, decimal_t *from2, decimal_t *to)
return error;
}
+int decimal_intg(decimal_t *from)
+{
+ int res;
+ dec1 *tmp_res;
+ tmp_res= remove_leading_zeroes(from, &res);
+ return res;
+}
+
int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
if (likely(from1->sign == from2->sign))