"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "c/lib/mvfuncs.c" between
mlr-5.9.0.tar.gz and mlr-5.9.1.tar.gz

About: Miller is like sed, awk, cut, join, and sort for name-indexed data such as CSV and tabular JSON.

mvfuncs.c  (mlr-5.9.0):mvfuncs.c  (mlr-5.9.1)
skipping to change at line 1093 skipping to change at line 1093
int overflowed = FALSE; int overflowed = FALSE;
if (a > 0LL) { if (a > 0LL) {
if (b < 0LL && c < 0LL) if (b < 0LL && c < 0LL)
overflowed = TRUE; overflowed = TRUE;
} else if (a < 0LL) { } else if (a < 0LL) {
if (b > 0LL && c > 0LL) if (b > 0LL && c > 0LL)
overflowed = TRUE; overflowed = TRUE;
} }
if (overflowed) { if (overflowed) {
return mv_from_float((double)a + (double)b); return mv_from_float((double)a - (double)b);
} else { } else {
return mv_from_int(c); return mv_from_int(c);
} }
} }
static mv_binary_func_t* minus_dispositions[MT_DIM][MT_DIM] = { static mv_binary_func_t* minus_dispositions[MT_DIM][MT_DIM] = {
// ERROR ABSENT EMPTY STRING INT FLOAT BOOL // ERROR ABSENT EMPTY STRING INT FLOAT BOOL
/*ERROR*/ {_err, _err, _err, _err, _err, _err, _err}, /*ERROR*/ {_err, _err, _err, _err, _err, _err, _err},
/*ABSENT*/ {_err, _a, _a, _err, _2, _2, _err}, /*ABSENT*/ {_err, _a, _a, _err, _2, _2, _err},
/*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err}, /*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err},
skipping to change at line 1195 skipping to change at line 1195
static mv_t divide_f_fi(mv_t* pa, mv_t* pb) { static mv_t divide_f_fi(mv_t* pa, mv_t* pb) {
double a = pa->u.fltv; double a = pa->u.fltv;
double b = (double)pb->u.intv; double b = (double)pb->u.intv;
return mv_from_float(a / b); return mv_from_float(a / b);
} }
static mv_t divide_f_if(mv_t* pa, mv_t* pb) { static mv_t divide_f_if(mv_t* pa, mv_t* pb) {
double a = (double)pa->u.intv; double a = (double)pa->u.intv;
double b = pb->u.fltv; double b = pb->u.fltv;
return mv_from_float(a / b); return mv_from_float(a / b);
} }
static mv_t divide_i_ii(mv_t* pa, mv_t* pb) { static mv_t divide_n_ii(mv_t* pa, mv_t* pb) {
long long a = pa->u.intv; long long a = pa->u.intv;
long long b = pb->u.intv; long long b = pb->u.intv;
if (b == 0LL) { // Compute inf/nan as with floats rather than fatal runti me FPE on integer divide by zero if (b == 0LL) { // Compute inf/nan as with floats rather than fatal runti me FPE on integer divide by zero
return mv_from_float((double)a / (double)b); return mv_from_float((double)a / (double)b);
} }
long long r = a % b; long long r = a % b;
// Pythonic division, not C division. // Pythonic division, not C division.
if (r == 0LL) { if (r == 0LL) {
return mv_from_int(a / b); return mv_from_int(a / b);
} else { } else {
return mv_from_float((double)a / (double)b); return mv_from_float((double)a / (double)b);
} }
} }
static mv_binary_func_t* divide_dispositions[MT_DIM][MT_DIM] = { static mv_binary_func_t* divide_dispositions[MT_DIM][MT_DIM] = {
// ERROR ABSENT EMPTY STRING INT FLOAT BOOL // ERROR ABSENT EMPTY STRING INT FLOAT BOOL
/*ERROR*/ {_err, _err, _err, _err, _err, _err, _err}, /*ERROR*/ {_err, _err, _err, _err, _err, _err, _err},
/*ABSENT*/ {_err, _a, _a, _err, _i0, _f0, _err}, /*ABSENT*/ {_err, _a, _a, _err, _i0, _f0, _err},
/*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err}, /*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err},
/*STRING*/ {_err, _err, _err, _err, _err, _err, _err}, /*STRING*/ {_err, _err, _err, _err, _err, _err, _err},
/*INT*/ {_err, _1, _emt, _err, divide_i_ii, divide_f_if, _err}, /*INT*/ {_err, _1, _emt, _err, divide_n_ii, divide_f_if, _err},
/*FLOAT*/ {_err, _1, _emt, _err, divide_f_fi, divide_f_ff, _err}, /*FLOAT*/ {_err, _1, _emt, _err, divide_f_fi, divide_f_ff, _err},
/*BOOL*/ {_err, _err, _err, _err, _err, _err, _err}, /*BOOL*/ {_err, _err, _err, _err, _err, _err, _err},
}; };
mv_t x_xx_divide_func(mv_t* pval1, mv_t* pval2) { return (divide_dispositions[pv al1->type][pval2->type])(pval1,pval2); } mv_t x_xx_divide_func(mv_t* pval1, mv_t* pval2) { return (divide_dispositions[pv al1->type][pval2->type])(pval1,pval2); }
// ---------------------------------------------------------------- // ----------------------------------------------------------------
static mv_t idiv_f_ff(mv_t* pa, mv_t* pb) { static mv_t idiv_f_ff(mv_t* pa, mv_t* pb) {
double a = pa->u.fltv; double a = pa->u.fltv;
double b = pb->u.fltv; double b = pb->u.fltv;
skipping to change at line 1293 skipping to change at line 1293
static mv_t oplus_f_fi(mv_t* pa, mv_t* pb) { static mv_t oplus_f_fi(mv_t* pa, mv_t* pb) {
double a = pa->u.fltv; double a = pa->u.fltv;
double b = (double)pb->u.intv; double b = (double)pb->u.intv;
return mv_from_float(a + b); return mv_from_float(a + b);
} }
static mv_t oplus_f_if(mv_t* pa, mv_t* pb) { static mv_t oplus_f_if(mv_t* pa, mv_t* pb) {
double a = (double)pa->u.intv; double a = (double)pa->u.intv;
double b = pb->u.fltv; double b = pb->u.fltv;
return mv_from_float(a + b); return mv_from_float(a + b);
} }
static mv_t oplus_n_ii(mv_t* pa, mv_t* pb) { static mv_t oplus_i_ii(mv_t* pa, mv_t* pb) {
long long a = pa->u.intv; long long a = pa->u.intv;
long long b = pb->u.intv; long long b = pb->u.intv;
long long c = a + b; long long c = a + b;
return mv_from_int(c); return mv_from_int(c);
} }
static mv_binary_func_t* oplus_dispositions[MT_DIM][MT_DIM] = { static mv_binary_func_t* oplus_dispositions[MT_DIM][MT_DIM] = {
// ERROR ABSENT EMPTY STRING INT FLOAT BOOL // ERROR ABSENT EMPTY STRING INT FLOAT BOOL
/*ERROR*/ {_err, _err, _err, _err, _err, _err, _err}, /*ERROR*/ {_err, _err, _err, _err, _err, _err, _err},
/*ABSENT*/ {_err, _a, _a, _err, _2, _2, _err}, /*ABSENT*/ {_err, _a, _a, _err, _2, _2, _err},
/*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err}, /*EMPTY*/ {_err, _a, _emt, _err, _emt, _emt, _err},
/*STRING*/ {_err, _err, _err, _err, _err, _err, _err}, /*STRING*/ {_err, _err, _err, _err, _err, _err, _err},
/*INT*/ {_err, _1, _emt, _err, oplus_n_ii, oplus_f_if, _err}, /*INT*/ {_err, _1, _emt, _err, oplus_i_ii, oplus_f_if, _err},
/*FLOAT*/ {_err, _1, _emt, _err, oplus_f_fi, oplus_f_ff, _err}, /*FLOAT*/ {_err, _1, _emt, _err, oplus_f_fi, oplus_f_ff, _err},
/*BOOL*/ {_err, _err, _err, _err, _err, _err, _err}, /*BOOL*/ {_err, _err, _err, _err, _err, _err, _err},
}; };
mv_t x_xx_oplus_func(mv_t* pval1, mv_t* pval2) { return (oplus_dispositions[pval 1->type][pval2->type])(pval1,pval2); } mv_t x_xx_oplus_func(mv_t* pval1, mv_t* pval2) { return (oplus_dispositions[pval 1->type][pval2->type])(pval1,pval2); }
// ---------------------------------------------------------------- // ----------------------------------------------------------------
static mv_t ominus_f_ff(mv_t* pa, mv_t* pb) { static mv_t ominus_f_ff(mv_t* pa, mv_t* pb) {
double a = pa->u.fltv; double a = pa->u.fltv;
double b = pb->u.fltv; double b = pb->u.fltv;
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)