~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/decimal.cc

  • Committer: Monty Taylor
  • Date: 2010-02-05 08:11:15 UTC
  • mfrom: (1283 build)
  • mto: (1273.13.43 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: mordred@inaugust.com-20100205081115-dr82nvrwv4lvw7sd
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
 
116
116
using namespace std;
117
117
 
 
118
namespace drizzled
 
119
{
118
120
 
119
121
/*
120
122
  Internally decimal numbers are stored base 10^9 (see DIG_BASE below)
920
922
  if (endp+1 < end_of_string && (*endp == 'e' || *endp == 'E'))
921
923
  {
922
924
    int str_error;
923
 
    const int64_t exponent= my_strtoll10(endp+1, (char**) &end_of_string,
924
 
                                    &str_error);
 
925
    const int64_t exponent= internal::my_strtoll10(endp+1, (char**) &end_of_string,
 
926
                                                   &str_error);
925
927
 
926
928
    if (end_of_string != endp +1)               /* If at least one digit */
927
929
    {
974
976
  rc = decimal2string(from, strbuf, &len, 0, 0, 0);
975
977
  end= strbuf + len;
976
978
 
977
 
  *to= my_strtod(strbuf, &end, &error);
 
979
  *to= internal::my_strtod(strbuf, &end, &error);
978
980
 
979
981
  return (rc != E_DEC_OK) ? rc : (error ? E_DEC_OVERFLOW : E_DEC_OK);
980
982
}
995
997
{
996
998
  char buff[FLOATING_POINT_BUFFER], *end;
997
999
  int res;
998
 
  end= buff + my_gcvt(from, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
 
1000
  end= buff + internal::my_gcvt(from,
 
1001
                                internal::MY_GCVT_ARG_DOUBLE,
 
1002
                                sizeof(buff) - 1, buff, NULL);
999
1003
  res= string2decimal(buff, to, &end);
1000
1004
  return(res);
1001
1005
}
2343
2347
  return do_div_mod(from1, from2, 0, to, 0);
2344
2348
}
2345
2349
 
 
2350
} /* namespace drizzled */
 
2351
 
2346
2352
#ifdef MAIN
2347
2353
 
2348
2354
int full= 0;
2486
2492
  int res;
2487
2493
 
2488
2494
  res=uint64_t2decimal(from, &a);
2489
 
  int64_t10_to_str(from,s,10);
 
2495
  internal::int64_t10_to_str(from,s,10);
2490
2496
  printf("%-40s => res=%d    ", s, res);
2491
2497
  print_decimal(&a, orig, res, ex);
2492
2498
  printf("\n");
2498
2504
  int res;
2499
2505
 
2500
2506
  res=int64_t2decimal(from, &a);
2501
 
  int64_t10_to_str(from,s,-10);
 
2507
  internal::int64_t10_to_str(from,s,-10);
2502
2508
  printf("%-40s => res=%d    ", s, res);
2503
2509
  print_decimal(&a, orig, res, ex);
2504
2510
  printf("\n");
2514
2520
  string2decimal(s, &a, &end);
2515
2521
  res=decimal2uint64_t(&a, &x);
2516
2522
  if (full) dump_decimal(&a);
2517
 
  int64_t10_to_str(x,s1,10);
 
2523
  internal::int64_t10_to_str(x,s1,10);
2518
2524
  printf("%-40s => res=%d    %s\n", s, res, s1);
2519
2525
  check_result_code(res, ex);
2520
2526
  if (orig && strcmp(orig, s1))
2534
2540
  string2decimal(s, &a, &end);
2535
2541
  res=decimal2int64_t(&a, &x);
2536
2542
  if (full) dump_decimal(&a);
2537
 
  int64_t10_to_str(x,s1,-10);
 
2543
  internal::int64_t10_to_str(x,s1,-10);
2538
2544
  printf("%-40s => res=%d    %s\n", s, res, s1);
2539
2545
  check_result_code(res, ex);
2540
2546
  if (orig && strcmp(orig, s1))