本文整理匯總了C++中Interval::hasNaN方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::hasNaN方法的具體用法?C++ Interval::hasNaN怎麽用?C++ Interval::hasNaN使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::hasNaN方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: intervalToHex
std::string FloatFormat::intervalToHex (const Interval& interval) const
{
if (interval.empty())
return interval.hasNaN() ? "{ NaN }" : "{}";
else if (interval.lo() == interval.hi())
return (std::string(interval.hasNaN() ? "{ NaN, " : "{ ") +
floatToHex(interval.lo()) + " }");
else if (interval == Interval::unbounded(true))
return "<any>";
return (std::string(interval.hasNaN() ? "{ NaN } | " : "") +
"[" + floatToHex(interval.lo()) + ", " + floatToHex(interval.hi()) + "]");
}
示例2: convert
//! Return the range of numbers that might be used with this format to
//! represent a number within `x`.
Interval FloatFormat::convert (const Interval& x) const
{
Interval ret;
Interval tmp = x;
if (x.hasNaN())
{
// If NaN might be supported, NaN is a legal return value
if (m_hasNaN != NO)
ret |= TCU_NAN;
// If NaN might not be supported, any (non-NaN) value is legal,
// _subject_ to clamping. Hence we modify tmp, not ret.
if (m_hasNaN != YES)
tmp = Interval::unbounded();
}
// Round both bounds _inwards_ to closest representable values.
if (!tmp.empty())
ret |= clampValue(round(tmp.lo(), true)) | clampValue(round(tmp.hi(), false));
// If this format's precision is not exact, the (possibly out-of-bounds)
// original value is also a possible result.
if (!m_exactPrecision)
ret |= x;
return ret;
}