~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/decimal.h

  • Committer: Brian Aker
  • Date: 2010-10-24 01:34:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1875.
  • Revision ID: brian@tangent.org-20101024013439-w9r8qtmt5ihnqtkd
Encapsulate table_name from table_list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
int decimal_is_zero(const decimal_t *from);
64
64
void max_decimal(int precision, int frac, decimal_t *to);
65
65
 
66
 
inline int string2decimal(char *from, decimal_t *to, char **end)
67
 
{
68
 
  return internal_str2dec(from, to, end, false);
69
 
}
 
66
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
70
67
 
71
68
/* set a decimal_t to zero */
72
69
 
73
 
inline void decimal_make_zero(decimal_t *dec)
74
 
{                                                           
75
 
  dec->buf[0]=0;
76
 
  dec->intg=1;
77
 
  dec->frac=0;
78
 
  dec->sign=0; 
79
 
}
 
70
#define decimal_make_zero(dec)        do {                \
 
71
                                        (dec)->buf[0]=0;    \
 
72
                                        (dec)->intg=1;      \
 
73
                                        (dec)->frac=0;      \
 
74
                                        (dec)->sign=0;      \
 
75
                                      } while(0)
80
76
 
81
77
/*
82
78
  returns the length of the buffer to hold string representation
83
79
  of the decimal (including decimal dot, possible sign and \0)
84
80
*/
85
81
 
86
 
inline int decimal_string_size(const decimal_t *dec)
87
 
{
88
 
  return (dec->intg ? dec->intg : 1) + dec->frac + (dec->frac > 0) + 2;
89
 
}
 
82
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
 
83
                                  (dec)->frac + ((dec)->frac > 0) + 2)
90
84
 
91
85
/* negate a decimal */
92
 
inline void decimal_neg(decimal_t *dec)
93
 
{
94
 
  dec->sign^=1;
95
 
}
 
86
#define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
96
87
 
97
88
/*
98
89
  conventions: