mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
new api per hf request:
string2decimal_fixed decimal_round(from, to) decimal_make_zero decimal_string_size decimal_neg strings/decimal.c: new api per hf request: string2decimal_fixed decimal_round(from, to) decimal_make_zero
This commit is contained in:
@ -30,6 +30,7 @@ typedef struct st_decimal {
|
||||
|
||||
int decimal2string(decimal *from, char *to, int *to_len);
|
||||
int string2decimal(char *from, decimal *to, char **end);
|
||||
int string2decimal_fixed(char *from, decimal *to, char **end);
|
||||
int decimal2ulonglong(decimal *from, ulonglong *to);
|
||||
int ulonglong2decimal(ulonglong from, decimal *to);
|
||||
int decimal2longlong(decimal *from, longlong *to);
|
||||
@ -49,14 +50,34 @@ int decimal_cmp(decimal *from1, decimal *from2);
|
||||
int decimal_mul(decimal *from1, decimal *from2, decimal *to);
|
||||
int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr);
|
||||
int decimal_mod(decimal *from1, decimal *from2, decimal *to);
|
||||
int decimal_round(decimal *dec, int new_scale, dec_round_mode mode);
|
||||
int decimal_round(decimal *from, decimal *to, int new_scale, dec_round_mode mode);
|
||||
|
||||
/*
|
||||
the following works only on special "zero" decimal, not on any
|
||||
decimal that happen to evaluate to zero
|
||||
*/
|
||||
|
||||
#define decimal_is_zero(dec) ((dec)->intg1==1 && (dec)->frac1==0 && (dec)->buf[0]==0)
|
||||
|
||||
/* set a decimal to zero */
|
||||
|
||||
#define decimal_make_zero(dec) do { \
|
||||
(dec)->buf[0]=0; \
|
||||
(dec)->intg=1; \
|
||||
(dec)->frac=0; \
|
||||
(dec)->sign=0; \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
returns the length of the buffer to hold string representation
|
||||
of the decimal
|
||||
*/
|
||||
|
||||
#define decimal_string_size(dec) ((dec)->intg + (dec)->frac + ((dec)->frac > 0) + 1)
|
||||
|
||||
/* negate a decimal */
|
||||
#define decimal_neg(dec) do { (dec)->sign=!(dec)->sign; } while(0)
|
||||
|
||||
/*
|
||||
conventions:
|
||||
|
||||
|
Reference in New Issue
Block a user