
Module: ppl/ppl Branch: floating_point Commit: 8c02f7d8aa8325c3771e4eb66da031d7e05c7b0b URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=8c02f7d8aa832...
Author: Fabio Bossi bossi@cs.unipr.it Date: Tue Oct 5 15:34:20 2010 +0200
Never add a rounding error when casting 1.
---
src/linearize.hh | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/linearize.hh b/src/linearize.hh index 5374a93..1a06b84 100644 --- a/src/linearize.hh +++ b/src/linearize.hh @@ -601,10 +601,11 @@ cast_linearize(const Cast_Operator<Target>& cast_expr, return false; if (!is_less_precise_than(analyzed_format, cast_arg->type().floating_point_format()) || - result == FP_Linear_Form(FP_Interval_Type(0))) + result == FP_Linear_Form(FP_Interval_Type(0)) || + result == FP_Linear_Form(FP_Interval_Type(1))) /* - We are casting to a more precise format or casting the 0 value. - Do not add errors. + We are casting to a more precise format or casting + a definitely safe value: do not add errors. */ return true; } @@ -614,10 +615,11 @@ cast_linearize(const Cast_Operator<Target>& cast_expr, return false; result = FP_Linear_Form(expr_value); if (is_less_precise_than(Float<analyzer_format>::Binary::floating_point_format, analyzed_format) || - result == FP_Linear_Form(FP_Interval_Type(0))) + result == FP_Linear_Form(FP_Interval_Type(0)) || + result == FP_Linear_Form(FP_Interval_Type(1))) /* - We are casting to a more precise format or casting the 0 value. - Do not add errors. + We are casting to a more precise format or casting + a definitely safe value: do not add errors. */ return true; }