Commit dc2e9d01 authored by serg@serg.mylan's avatar serg@serg.mylan

int decimal_is_zero(decimal *from);

parent 566b0707
...@@ -51,13 +51,7 @@ int decimal_mul(decimal *from1, decimal *from2, decimal *to); ...@@ -51,13 +51,7 @@ int decimal_mul(decimal *from1, decimal *from2, decimal *to);
int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr); int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr);
int decimal_mod(decimal *from1, decimal *from2, decimal *to); int decimal_mod(decimal *from1, decimal *from2, decimal *to);
int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode); int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode);
int decimal_is_zero(decimal *from);
/*
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 */ /* set a decimal to zero */
......
...@@ -1240,6 +1240,16 @@ int decimal_cmp(decimal *from1, decimal *from2) ...@@ -1240,6 +1240,16 @@ int decimal_cmp(decimal *from1, decimal *from2)
return from1->sign > from2->sign ? -1 : 1; return from1->sign > from2->sign ? -1 : 1;
} }
int decimal_is_zero(decimal *from)
{
dec1 *buf1=from->buf,
*end=buf1+ROUND_UP(from->intg)+ROUND_UP(from->frac);
while (buf1 < end)
if (*buf1++)
return 0;
return 1;
}
/* /*
multiply two decimals multiply two decimals
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment