MySQL  8.0.16
Source Code Documentation
my_decimal.h
Go to the documentation of this file.
1 /* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef MY_DECIMAL_INCLUDED
24 #define MY_DECIMAL_INCLUDED
25 
26 /**
27  @file
28 
29  It is interface module to fixed precision decimals library.
30 
31  Most functions use 'uint mask' as parameter, if during operation error
32  which fit in this mask is detected then it will be processed automatically
33  here. (errors are E_DEC_* constants, see include/decimal.h)
34 
35  Most function are just inline wrappers around library calls
36 */
37 
38 #include <stdlib.h>
39 #include <sys/types.h>
40 #include <algorithm>
41 
42 #include "decimal.h"
43 #include "m_ctype.h"
44 #include "my_dbug.h"
45 #include "my_inttypes.h"
46 #include "my_macros.h"
47 #include "sql_string.h" /* String */
48 
49 struct MYSQL_TIME;
50 
51 #define DECIMAL_LONGLONG_DIGITS 22
52 
53 /** maximum length of buffer in our big digits (uint32). */
54 #define DECIMAL_BUFF_LENGTH 9
55 
56 /* the number of digits that my_decimal can possibly contain */
57 #define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
58 
59 /**
60  maximum guaranteed precision of number in decimal digits (number of our
61  digits * number of decimal digits in one our big digit - number of decimal
62  digits in one our big digit decreased by 1 (because we always put decimal
63  point on the border of our big digits))
64 */
65 #define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8 * 2)
66 #define DECIMAL_MAX_SCALE 30
67 #define DECIMAL_NOT_SPECIFIED 31
68 
69 /**
70  maximum length of string representation (number of maximum decimal
71  digits + 1 position for sign + 1 position for decimal point, no terminator)
72 */
73 #define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
74 
75 /**
76  maximum size of packet length.
77 */
78 #define DECIMAL_MAX_FIELD_SIZE DECIMAL_MAX_PRECISION
79 
80 inline uint my_decimal_size(uint precision, uint scale) {
81  /*
82  Always allocate more space to allow library to put decimal point
83  where it want
84  */
85  return decimal_size(precision, scale) + 1;
86 }
87 
88 inline int my_decimal_int_part(uint precision, uint decimals) {
89  return precision - ((decimals == DECIMAL_NOT_SPECIFIED) ? 0 : decimals);
90 }
91 
92 /**
93  my_decimal class limits 'decimal_t' type to what we need in MySQL.
94 
95  It contains internally all necessary space needed by the instance so
96  no extra memory is needed. Objects should be moved using copy CTOR
97  or assignment operator, rather than memcpy/memmove.
98 */
99 
100 class my_decimal : public decimal_t {
101 /*
102  Several of the routines in strings/decimal.c have had buffer
103  overrun/underrun problems. These are *not* caught by valgrind.
104  To catch them, we allocate dummy fields around the buffer,
105  and test that their values do not change.
106  */
107 #if !defined(DBUG_OFF)
108  int foo1;
109 #endif
110 
112 
113 #if !defined(DBUG_OFF)
114  int foo2;
115  static const int test_value = 123;
116 #endif
117 
118  public:
119  my_decimal(const my_decimal &rhs) : decimal_t(rhs) {
120  rhs.sanity_check();
121 #if !defined(DBUG_OFF)
122  foo1 = test_value;
123  foo2 = test_value;
124 #endif
125  for (uint i = 0; i < DECIMAL_BUFF_LENGTH; i++) buffer[i] = rhs.buffer[i];
126  buf = buffer;
127  }
128 
130  sanity_check();
131  rhs.sanity_check();
132  if (this == &rhs) return *this;
133  decimal_t::operator=(rhs);
134  for (uint i = 0; i < DECIMAL_BUFF_LENGTH; i++) buffer[i] = rhs.buffer[i];
135  buf = buffer;
136  return *this;
137  }
138 
139  void init() {
140 #if !defined(DBUG_OFF)
141  foo1 = test_value;
142  foo2 = test_value;
143 #endif
144  /*
145  Do not initialize more of the base class,
146  we want to catch uninitialized use.
147  */
149  buf = buffer;
150  }
151 
152  my_decimal() { init(); }
153 
154 #ifndef DBUG_OFF
156 #endif // DBUG_OFF
157 
158  void sanity_check() const {
161  DBUG_ASSERT(buf == buffer);
162  }
163 
164  bool sign() const { return decimal_t::sign; }
165  void sign(bool s) { decimal_t::sign = s; }
166  uint precision() const { return intg + frac; }
167 
168  /** Swap two my_decimal values */
169  void swap(my_decimal &rhs) { std::swap(*this, rhs); }
170 
171 #ifndef MYSQL_SERVER
172  // Error reporting in server code only.
173  int check_result(uint, int result) const { return result; }
174 #else
175  int check_result(uint, int result) const;
176 #endif
177 };
178 
179 #ifndef DBUG_OFF
180 void print_decimal(const my_decimal *dec);
181 void print_decimal_buff(const my_decimal *dec, const uchar *ptr, int length);
182 const char *dbug_decimal_as_string(char *buff, const my_decimal *val);
183 #else
184 #define dbug_decimal_as_string(A) NULL
185 #endif
186 
187 bool str_set_decimal(uint mask, const my_decimal *val, uint fixed_prec,
188  uint fixed_dec, char filler, String *str,
189  const CHARSET_INFO *cs);
190 
191 extern my_decimal decimal_zero;
192 
193 inline void max_my_decimal(my_decimal *to, int precision, int frac) {
194  DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) &&
195  (frac <= DECIMAL_MAX_SCALE));
196  max_decimal(precision, frac, to);
197 }
198 
201 }
202 
203 inline int check_result_and_overflow(uint mask, int result, my_decimal *val) {
204  if (val->check_result(mask, result) & E_DEC_OVERFLOW) {
205  bool sign = val->sign();
206  val->sanity_check();
208  val->sign(sign);
209  }
210  /*
211  Avoid returning negative zero, cfr. decimal_cmp()
212  For result == E_DEC_DIV_ZERO *val has not been assigned.
213  */
214  if (result != E_DEC_DIV_ZERO && val->sign() && decimal_is_zero(val))
215  val->sign(false);
216  return result;
217 }
218 
220  bool unsigned_flag) {
221  /* Precision can't be negative thus ignore unsigned_flag when length is 0. */
222  DBUG_ASSERT(length || !scale);
223  uint retval =
224  (uint)(length - (scale > 0 ? 1 : 0) - (unsigned_flag || !length ? 0 : 1));
225  return retval;
226 }
227 
229  uint8 scale,
230  bool unsigned_flag) {
231  /*
232  When precision is 0 it means that original length was also 0. Thus
233  unsigned_flag is ignored in this case.
234  */
235  DBUG_ASSERT(precision || !scale);
236  uint32 retval = (uint32)(precision + (scale > 0 ? 1 : 0) +
237  (unsigned_flag || !precision ? 0 : 1));
238  return retval;
239 }
240 
241 inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
242  bool unsigned_flag) {
243  /*
244  When precision is 0 it means that original length was also 0. Thus
245  unsigned_flag is ignored in this case.
246  */
247  DBUG_ASSERT(precision || !scale);
249  return my_decimal_precision_to_length_no_truncation(precision, scale,
250  unsigned_flag);
251 }
252 
253 inline int my_decimal_string_length(const my_decimal *d) {
254  /* length of string representation including terminating '\0' */
255  return decimal_string_size(d);
256 }
257 
258 inline int my_decimal_get_binary_size(uint precision, uint scale) {
259  return decimal_bin_size((int)precision, (int)scale);
260 }
261 
262 inline void my_decimal2decimal(const my_decimal *from, my_decimal *to) {
263  *to = *from;
264 }
265 
266 int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec,
267  int scale);
268 
269 inline int binary2my_decimal(uint mask, const uchar *bin, my_decimal *d,
270  int prec, int scale) {
271  return d->check_result(mask, bin2decimal(bin, d, prec, scale));
272 }
273 
275  /*
276  We need the up-cast here, since my_decimal has sign() member functions,
277  which conflicts with decimal_t::size
278  (and decimal_make_zero is a macro, rather than a funcion).
279  */
280  decimal_make_zero(static_cast<decimal_t *>(d));
281  return 0;
282 }
283 
284 inline bool my_decimal_is_zero(const my_decimal *decimal_value) {
285  return decimal_is_zero(decimal_value);
286 }
287 
288 inline int my_decimal_round(uint mask, const my_decimal *from, int scale,
289  bool truncate, my_decimal *to) {
290  return from->check_result(
291  mask, decimal_round(from, to, scale, (truncate ? TRUNCATE : HALF_UP)));
292 }
293 
294 inline int my_decimal_floor(uint mask, const my_decimal *from, my_decimal *to) {
295  return from->check_result(mask, decimal_round(from, to, 0, FLOOR));
296 }
297 
298 inline int my_decimal_ceiling(uint mask, const my_decimal *from,
299  my_decimal *to) {
300  return from->check_result(mask, decimal_round(from, to, 0, CEILING));
301 }
302 
303 inline bool str_set_decimal(const my_decimal *val, String *str,
304  const CHARSET_INFO *cs) {
305  return str_set_decimal(E_DEC_FATAL_ERROR, val, 0, 0, 0, str, cs);
306 }
307 
308 int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec,
309  uint fixed_dec, char filler, String *str);
310 
311 inline int my_decimal2int(uint mask, const my_decimal *d, bool unsigned_flag,
312  longlong *l) {
313  my_decimal rounded;
314  /* decimal_round can return only E_DEC_TRUNCATED */
315  decimal_round(d, &rounded, 0, HALF_UP);
316  return d->check_result(
317  mask, (unsigned_flag ? decimal2ulonglong(&rounded, (ulonglong *)l)
318  : decimal2longlong(&rounded, l)));
319 }
320 
321 inline int my_decimal2double(uint, const my_decimal *d, double *result) {
322  /* No need to call check_result as this will always succeed */
323  return decimal2double(d, result);
324 }
325 
326 inline int my_decimal2lldiv_t(uint mask, const my_decimal *d, lldiv_t *to) {
327  return d->check_result(mask, decimal2lldiv_t(d, to));
328 }
329 
330 inline int str2my_decimal(uint mask, const char *str, my_decimal *d,
331  const char **end) {
332  return check_result_and_overflow(mask, string2decimal(str, d, end), d);
333 }
334 
335 int str2my_decimal(uint mask, const char *from, size_t length,
336  const CHARSET_INFO *charset, my_decimal *decimal_value);
337 
338 inline int string2my_decimal(uint mask, const String *str, my_decimal *d) {
339  return str2my_decimal(mask, str->ptr(), (uint)str->length(), str->charset(),
340  d);
341 }
342 
343 my_decimal *date2my_decimal(const MYSQL_TIME *ltime, my_decimal *dec);
344 my_decimal *time2my_decimal(const MYSQL_TIME *ltime, my_decimal *dec);
345 my_decimal *timeval2my_decimal(const struct timeval *tm, my_decimal *dec);
346 
347 inline int double2my_decimal(uint mask, double val, my_decimal *d) {
348  return check_result_and_overflow(mask, double2decimal(val, d), d);
349 }
350 
351 inline int int2my_decimal(uint mask, longlong i, bool unsigned_flag,
352  my_decimal *d) {
353  return d->check_result(mask,
354  (unsigned_flag ? ulonglong2decimal((ulonglong)i, d)
355  : longlong2decimal(i, d)));
356 }
357 
358 inline void my_decimal_neg(decimal_t *arg) {
359  // Avoid returning negative zero, cfr. decimal_cmp()
360  if (decimal_is_zero(arg)) {
361  arg->sign = 0;
362  return;
363  }
364  arg->sign ^= 1;
365 }
366 
367 inline int my_decimal_add(uint mask, my_decimal *res, const my_decimal *a,
368  const my_decimal *b) {
369  return check_result_and_overflow(mask, decimal_add(a, b, res), res);
370 }
371 
372 inline int my_decimal_sub(uint mask, my_decimal *res, const my_decimal *a,
373  const my_decimal *b) {
374  return check_result_and_overflow(mask, decimal_sub(a, b, res), res);
375 }
376 
377 inline int my_decimal_mul(uint mask, my_decimal *res, const my_decimal *a,
378  const my_decimal *b) {
379  return check_result_and_overflow(mask, decimal_mul(a, b, res), res);
380 }
381 
382 inline int my_decimal_div(uint mask, my_decimal *res, const my_decimal *a,
383  const my_decimal *b, int div_scale_inc) {
384  return check_result_and_overflow(mask, decimal_div(a, b, res, div_scale_inc),
385  res);
386 }
387 
388 inline int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
389  const my_decimal *b) {
390  return check_result_and_overflow(mask, decimal_mod(a, b, res), res);
391 }
392 
393 /**
394  @return
395  @retval -1 if a @< b
396  @retval 1 if a @> b
397  @retval 0 if a == b
398 */
399 inline int my_decimal_cmp(const my_decimal *a, const my_decimal *b) {
400  return decimal_cmp(a, b);
401 }
402 
403 inline bool operator<(const my_decimal &lhs, const my_decimal &rhs) {
404  return my_decimal_cmp(&lhs, &rhs) < 0;
405 }
406 
407 inline bool operator!=(const my_decimal &lhs, const my_decimal &rhs) {
408  return my_decimal_cmp(&lhs, &rhs) != 0;
409 }
410 
411 inline int my_decimal_intg(const my_decimal *a) { return decimal_intg(a); }
412 
413 void my_decimal_trim(ulong *precision, uint *scale);
414 
415 #endif // MY_DECIMAL_INCLUDED
int int2my_decimal(uint mask, longlong i, bool unsigned_flag, my_decimal *d)
Definition: my_decimal.h:351
bool sign() const
Definition: my_decimal.h:164
my_decimal * time2my_decimal(const MYSQL_TIME *ltime, my_decimal *dec)
Convert time value to my_decimal in format hhmmss.ffffff.
Definition: my_decimal.cc:314
Some common macros.
unsigned long long int ulonglong
Definition: my_inttypes.h:69
unsigned char uchar
Definition: my_inttypes.h:49
int intg
Definition: decimal.h:52
Our own string classes, used pervasively throughout the executor.
uint32 my_decimal_precision_to_length(uint precision, uint8 scale, bool unsigned_flag)
Definition: my_decimal.h:241
int double2decimal(double from, decimal_t *to)
Definition: decimal.cc:1041
int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a, const my_decimal *b)
Definition: my_decimal.h:388
int string2my_decimal(uint mask, const String *str, my_decimal *d)
Definition: my_decimal.h:338
decimal_digit_t * buf
Definition: decimal.h:54
static mi_bit_type mask[]
Definition: mi_packrec.cc:138
~my_decimal()
Definition: my_decimal.h:155
int my_decimal_get_binary_size(uint precision, uint scale)
Definition: my_decimal.h:258
Some integer typedefs for easier portability.
void max_decimal(int precision, int frac, decimal_t *to)
Definition: decimal.cc:392
int decimal_cmp(const decimal_t *from1, const decimal_t *from2)
Definition: decimal.cc:2037
int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec, uint fixed_dec, char filler, String *str)
Converting decimal to string.
Definition: my_decimal.cc:119
void my_decimal_trim(ulong *precision, uint *scale)
Definition: my_decimal.cc:331
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale)
Definition: decimal.cc:1442
int my_decimal2int(uint mask, const my_decimal *d, bool unsigned_flag, longlong *l)
Definition: my_decimal.h:311
int frac
Definition: decimal.h:52
int foo2
Definition: my_decimal.h:114
unsigned char uint8
Definition: my_inttypes.h:51
int decimal2lldiv_t(const decimal_t *from, lldiv_t *to)
Convert decimal to lldiv_t.
Definition: decimal.cc:1171
int my_decimal_string_length(const my_decimal *d)
Definition: my_decimal.h:253
Definition: decimal.h:38
my_decimal(const my_decimal &rhs)
Definition: my_decimal.h:119
my_decimal()
Definition: my_decimal.h:152
int my_decimal_round(uint mask, const my_decimal *from, int scale, bool truncate, my_decimal *to)
Definition: my_decimal.h:288
int my_decimal_ceiling(uint mask, const my_decimal *from, my_decimal *to)
Definition: my_decimal.h:298
int32 decimal_digit_t
Definition: decimal.h:40
int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
Definition: decimal.cc:2076
bool operator!=(const my_decimal &lhs, const my_decimal &rhs)
Definition: my_decimal.h:407
int my_decimal_mul(uint mask, my_decimal *res, const my_decimal *a, const my_decimal *b)
Definition: my_decimal.h:377
void my_decimal2decimal(const my_decimal *from, my_decimal *to)
Definition: my_decimal.h:262
int my_decimal_cmp(const my_decimal *a, const my_decimal *b)
Definition: my_decimal.h:399
static const int test_value
Definition: my_decimal.h:115
int longlong2decimal(longlong from, decimal_t *to)
Definition: decimal.cc:1087
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:159
int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
Definition: decimal.cc:2503
bool operator<(const my_decimal &lhs, const my_decimal &rhs)
Definition: my_decimal.h:403
#define set_if_smaller(a, b)
Definition: my_macros.h:67
int decimal2double(const decimal_t *from, double *to)
Definition: decimal.cc:1012
void max_internal_decimal(my_decimal *to)
Definition: my_decimal.h:199
bool my_decimal_is_zero(const my_decimal *decimal_value)
Definition: my_decimal.h:284
decimal_digit_t buffer[DECIMAL_BUFF_LENGTH]
Definition: my_decimal.h:111
int my_decimal_int_part(uint precision, uint decimals)
Definition: my_decimal.h:88
int decimal_bin_size(int precision, int scale)
Definition: decimal.cc:1586
#define DBUG_ASSERT(A)
Definition: my_dbug.h:128
uint my_decimal_size(uint precision, uint scale)
Definition: my_decimal.h:80
int foo1
Definition: my_decimal.h:108
int my_decimal2double(uint, const my_decimal *d, double *result)
Definition: my_decimal.h:321
void sanity_check() const
Definition: my_decimal.h:158
int decimal_div(const decimal_t *from1, const decimal_t *from2, decimal_t *to, int scale_incr)
Definition: decimal.cc:2471
my_decimal * date2my_decimal(const MYSQL_TIME *ltime, my_decimal *dec)
Convert datetime value to my_decimal in format YYYYMMDDhhmmss.ffffff.
Definition: my_decimal.cc:300
int my_decimal_floor(uint mask, const my_decimal *from, my_decimal *to)
Definition: my_decimal.h:294
void max_my_decimal(my_decimal *to, int precision, int frac)
Definition: my_decimal.h:193
uint precision() const
Definition: my_decimal.h:166
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
my_decimal class limits &#39;decimal_t&#39; type to what we need in MySQL.
Definition: my_decimal.h:100
int my_decimal_intg(const my_decimal *a)
Definition: my_decimal.h:411
#define E_DEC_FATAL_ERROR
Definition: decimal.h:145
int my_decimal_add(uint mask, my_decimal *res, const my_decimal *a, const my_decimal *b)
Definition: my_decimal.h:367
int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
Definition: decimal.cc:2027
int decimal_round(const decimal_t *from, decimal_t *to, int new_scale, decimal_round_mode mode)
Definition: decimal.cc:1608
unsigned int uint
Definition: uca-dump.cc:29
long long int longlong
Definition: my_inttypes.h:70
int binary2my_decimal(uint mask, const uchar *bin, my_decimal *d, int prec, int scale)
Definition: my_decimal.h:269
int decimal2longlong(decimal_t *from, longlong *to)
Definition: decimal.cc:1118
#define DECIMAL_NOT_SPECIFIED
Definition: my_decimal.h:67
#define DECIMAL_BUFF_LENGTH
maximum length of buffer in our big digits (uint32).
Definition: my_decimal.h:54
Definition: decimal.h:36
int my_decimal2lldiv_t(uint mask, const my_decimal *d, lldiv_t *to)
Definition: my_decimal.h:326
#define DECIMAL_MAX_SCALE
Definition: my_decimal.h:66
static void decimal_make_zero(decimal_t *dec)
Definition: decimal.h:113
int check_result_and_overflow(uint mask, int result, my_decimal *val)
Definition: my_decimal.h:203
void init()
Definition: my_decimal.h:139
Definition: m_ctype.h:358
const char * dbug_decimal_as_string(char *buff, const my_decimal *val)
Definition: my_decimal.cc:368
int decimal_is_zero(const decimal_t *from)
Definition: decimal.cc:2047
uint32 my_decimal_precision_to_length_no_truncation(uint precision, uint8 scale, bool unsigned_flag)
Definition: my_decimal.h:228
void print_decimal_buff(const my_decimal *dec, const uchar *ptr, int length)
Definition: my_decimal.cc:359
my_decimal decimal_zero
Definition: mysqld.cc:1250
int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec, int scale)
Definition: my_decimal.cc:212
Definition: mysql_time.h:64
int check_result(uint, int result) const
report result of decimal operation.
Definition: my_decimal.cc:55
#define DECIMAL_MAX_PRECISION
maximum guaranteed precision of number in decimal digits (number of our digits * number of decimal di...
Definition: my_decimal.h:65
int decimal2ulonglong(decimal_t *from, ulonglong *to)
Definition: decimal.cc:1094
void sign(bool s)
Definition: my_decimal.h:165
int my_decimal_div(uint mask, my_decimal *res, const my_decimal *a, const my_decimal *b, int div_scale_inc)
Definition: my_decimal.h:382
void print_decimal(const my_decimal *dec)
Definition: my_decimal.cc:346
my_decimal & operator=(const my_decimal &rhs)
Definition: my_decimal.h:129
int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
Definition: decimal.cc:2032
int string2decimal(const char *from, decimal_t *to, const char **end)
Definition: decimal.cc:872
#define E_DEC_OVERFLOW
Definition: decimal.h:139
bool str_set_decimal(uint mask, const my_decimal *val, uint fixed_prec, uint fixed_dec, char filler, String *str, const CHARSET_INFO *cs)
Converting decimal to string with character set conversion.
Definition: my_decimal.cc:168
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:581
uint my_decimal_length_to_precision(uint length, uint scale, bool unsigned_flag)
Definition: my_decimal.h:219
const CHARSET_INFO * charset() const
Definition: sql_string.h:232
A better implementation of the UNIX ctype(3) library.
int my_decimal_set_zero(my_decimal *d)
Definition: my_decimal.h:274
int str2my_decimal(uint mask, const char *str, my_decimal *d, const char **end)
Definition: my_decimal.h:330
void my_decimal_neg(decimal_t *arg)
Definition: my_decimal.h:358
const char * ptr() const
Definition: sql_string.h:240
void swap(my_decimal &rhs)
Swap two my_decimal values.
Definition: my_decimal.h:169
Definition: decimal.h:34
int ulonglong2decimal(ulonglong from, decimal_t *to)
Definition: decimal.cc:1082
int double2my_decimal(uint mask, double val, my_decimal *d)
Definition: my_decimal.h:347
int decimal_size(int precision, int scale)
Definition: decimal.cc:1561
unsigned long ulong
Definition: my_inttypes.h:46
bool sign
Definition: decimal.h:53
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
intg is the number of decimal digits (NOT number of decimal_digit_t&#39;s !) before the point frac is the...
Definition: decimal.h:51
size_t length() const
Definition: sql_string.h:233
int len
Definition: decimal.h:52
#define E_DEC_DIV_ZERO
Definition: decimal.h:140
static int decimal_string_size(const decimal_t *dec)
Returns the length of the buffer to hold string representation of the decimal (including decimal dot...
Definition: decimal.h:124
int decimal_intg(const decimal_t *from)
Definition: decimal.cc:2021
Definition: decimal.h:37
my_decimal * timeval2my_decimal(const struct timeval *tm, my_decimal *dec)
Convert timeval value to my_decimal.
Definition: my_decimal.cc:324
int my_decimal_sub(uint mask, my_decimal *res, const my_decimal *a, const my_decimal *b)
Definition: my_decimal.h:372