[PPL-devel] [GIT] ppl/ppl(floating_point): Never add a rounding error when casting the 0 value.
Fabio Bossi
bossi at cs.unipr.it
Tue Oct 5 10:51:55 CEST 2010
Module: ppl/ppl
Branch: floating_point
Commit: 500981d998d62c82210b01b5c22994e9c7ef1f4b
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=500981d998d62c82210b01b5c22994e9c7ef1f4b
Author: Fabio Bossi <bossi at cs.unipr.it>
Date: Tue Oct 5 10:51:03 2010 +0200
Never add a rounding error when casting the 0 value.
---
src/linearize.hh | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/linearize.hh b/src/linearize.hh
index 8767f80..5374a93 100644
--- a/src/linearize.hh
+++ b/src/linearize.hh
@@ -600,8 +600,12 @@ cast_linearize(const Cast_Operator<Target>& cast_expr,
if (!linearize(*cast_arg, oracle, lf_store, result))
return false;
if (!is_less_precise_than(analyzed_format,
- cast_arg->type().floating_point_format()))
- // We are casting to a more precise format. Do not add errors.
+ cast_arg->type().floating_point_format()) ||
+ result == FP_Linear_Form(FP_Interval_Type(0)))
+ /*
+ We are casting to a more precise format or casting the 0 value.
+ Do not add errors.
+ */
return true;
}
else {
@@ -609,8 +613,12 @@ cast_linearize(const Cast_Operator<Target>& cast_expr,
if (!oracle.get_integer_expr_value(*cast_arg, expr_value))
return false;
result = FP_Linear_Form(expr_value);
- if (is_less_precise_than(Float<analyzer_format>::Binary::floating_point_format, analyzed_format))
- // We are rounding to a less precise format. Do not add errors.
+ if (is_less_precise_than(Float<analyzer_format>::Binary::floating_point_format, analyzed_format) ||
+ result == FP_Linear_Form(FP_Interval_Type(0)))
+ /*
+ We are casting to a more precise format or casting the 0 value.
+ Do not add errors.
+ */
return true;
}
More information about the PPL-devel
mailing list