~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/str/format.cc

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include CMATH_H
21
23
#include <drizzled/function/str/format.h>
22
24
 
23
 
#include <limits>
24
 
 
25
 
using namespace std;
26
 
 
27
 
namespace drizzled
28
 
{
 
25
#if defined(CMATH_NAMESPACE)
 
26
using namespace CMATH_NAMESPACE;
 
27
#endif
29
28
 
30
29
/**
31
30
  Change a number to format '3,333,333,333.000'.
83
82
    my_decimal dec_val, rnd_dec, *res;
84
83
    res= args[0]->val_decimal(&dec_val);
85
84
    if ((null_value=args[0]->null_value))
86
 
      return 0;
 
85
      return 0; /* purecov: inspected */
87
86
    my_decimal_round(E_DEC_FATAL_ERROR, res, dec, false, &rnd_dec);
88
87
    my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str);
89
88
    str_length= str->length();
94
93
  {
95
94
    double nr= args[0]->val_real();
96
95
    if ((null_value=args[0]->null_value))
97
 
      return 0;
 
96
      return 0; /* purecov: inspected */
98
97
    nr= my_double_round(nr, (int64_t) dec, false, false);
99
98
    /* Here default_charset() is right as this is not an automatic conversion */
100
99
    str->set_real(nr, dec, default_charset());
101
 
    if (nr == numeric_limits<double>::quiet_NaN())
 
100
    if (isnan(nr))
102
101
      return str;
103
102
    str_length=str->length();
104
103
    if (nr < 0)
139
138
  args[1]->print(str, query_type);
140
139
  str->append(')');
141
140
}
142
 
 
143
 
} /* namespace drizzled */