solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit c1729e1192e5429511b3c05beb6e38bbb5e42f6d
parent 560673037c1a0c6f33b319f0d2bfd7c9f646f2a9
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 12 Jan 2017 18:07:07 +0100

Improve log message for reals not in range.

Make use of open ranges instead of nextafter-made reals.

Diffstat:
Msrc/parser/solparser.c | 20+++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/parser/solparser.c b/src/parser/solparser.c @@ -364,9 +364,23 @@ parse_real goto error; } - if(*dst < lower_bound || *dst > upper_bound) { - log_err(parser, real, "%g is not in [%g, %g].\n", - *dst, lower_bound, upper_bound); + if (*dst < lower_bound || *dst > upper_bound) { + double l = nextafter(lower_bound, -DBL_MAX); + double u = nextafter(upper_bound, DBL_MAX); + int l_excluded = (l == (double) (int) l); + int u_excluded = (u == (double) (int) u); + if (l_excluded && u_excluded) + log_err(parser, real, "%g is not in ]%g, %g[.\n", + *dst, l, u); + else if (l_excluded) + log_err(parser, real, "%g is not in ]%g, %g].\n", + *dst, l, upper_bound); + else if (u_excluded) + log_err(parser, real, "%g is not in [%g, %g[.\n", + *dst, lower_bound, u); + else + log_err(parser, real, "%g is not in [%g, %g].\n", + *dst, lower_bound, upper_bound); res = RES_BAD_ARG; goto error; }