Changeset: 44310b9a44ff for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=44310b9a44ff Modified Files: gdk/gdk_aggr.c Branch: default Log Message:
Check whether conversion to float caused overflow by checking for INFINITY. diffs (48 lines): diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -215,6 +215,7 @@ dofsum(const void *restrict values, oid volatile double lo, hi; double twopow = pow((double) FLT_RADIX, (double) (DBL_MAX_EXP - 1)); BUN nils = 0; + volatile flt f; ALGODEBUG fprintf(stderr, "#%s: floating point summation\n", func); /* we only deal with the two floating point types */ @@ -362,14 +363,16 @@ dofsum(const void *restrict values, oid pergroup[grp].partials = NULL; x = 2 * (hi + y); if (tp2 == TYPE_flt) { - if (x > GDK_flt_max || - x < GDK_flt_min) { + f = (flt) x; + if (isinf(f) || + isnan(f) || + is_flt_nil(f)) { if (abort_on_error) goto overflow; ((flt *) results)[grp] = flt_nil; nils++; } else - ((flt *) results)[grp] = (flt) x; + ((flt *) results)[grp] = f; } else if (is_dbl_nil(x)) { if (abort_on_error) goto overflow; @@ -432,13 +435,14 @@ dofsum(const void *restrict values, oid GDKfree(pergroup[grp].partials); pergroup[grp].partials = NULL; if (tp2 == TYPE_flt) { - if (hi > GDK_flt_max || hi < GDK_flt_min) { + f = (flt) hi; + if (isinf(f) || isnan(f) || is_flt_nil(f)) { if (abort_on_error) goto overflow; ((flt *) results)[grp] = flt_nil; nils++; } else - ((flt *) results)[grp] = (flt) hi; + ((flt *) results)[grp] = f; } else if (is_dbl_nil(hi)) { if (abort_on_error) goto overflow; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list