For the frange implementation with endpoints I'm about to contribute,
we need to set REAL_VALUE_TYPEs with negative infinity. The support
is already there in real.cc, but it is awkward to get at. One could
call real_inf() and then negate the value, but I've added the ability
to pass the sign argument like many of the existing real.* functions.
I've declared the functions in such a way to avoid changes to the
existing code base:
// Unchanged function returning true for either +-INF.
bool real_isinf (const REAL_VALUE_TYPE *r);
// New overload to be able to specify the sign.
bool real_isinf (const REAL_VALUE_TYPE *r, int sign);
// Replacement function for setting INF, defaults to +INF.
void real_inf (REAL_VALUE_TYPE *, int sign = 0);
gcc/ChangeLog:
* real.cc (real_isinf): New overload.
(real_inf): Add sign argument.
* real.h (real_isinf): New overload.
(real_inf): Add sign argument.
return (r->cl == rvc_inf);
}
+/* Determine whether a floating-point value X is infinite with SIGN. */
+
+bool
+real_isinf (const REAL_VALUE_TYPE *r, bool sign)
+{
+ return real_isinf (r) && r->sign == sign;
+}
+
/* Determine whether a floating-point value X is a NaN. */
bool
return &value;
}
-/* Fills R with +Inf. */
+/* Fills R with Inf with SIGN. */
void
-real_inf (REAL_VALUE_TYPE *r)
+real_inf (REAL_VALUE_TYPE *r, bool sign)
{
- get_inf (r, 0);
+ get_inf (r, sign);
}
/* Fills R with a NaN whose significand is described by STR. If QUIET,
/* Determine whether a floating-point value X is infinite. */
extern bool real_isinf (const REAL_VALUE_TYPE *);
+/* Determine whether a floating-point value X is infinite with SIGN. */
+extern bool real_isinf (const REAL_VALUE_TYPE *, bool sign);
+
/* Determine whether a floating-point value X is a NaN. */
extern bool real_isnan (const REAL_VALUE_TYPE *);
extern void real_from_target (REAL_VALUE_TYPE *, const long *,
format_helper);
-extern void real_inf (REAL_VALUE_TYPE *);
+extern void real_inf (REAL_VALUE_TYPE *, bool sign = false);
extern bool real_nan (REAL_VALUE_TYPE *, const char *, int, format_helper);