MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / ilogb

Function ilogb

include/half_float/half.hpp:4247–4257  ·  view source on GitHub ↗

Extract exponent. See also:** Documentation for [std::ilogb](https://en.cppreference.com/w/cpp/numeric/math/ilogb). \param arg number to query \return floating-point exponent \retval FP_ILOGB0 for zero \retval FP_ILOGBNAN for NaN \retval INT_MAX for infinity \exception FE_INVALID for 0 or infinite values

Source from the content-addressed store, hash-verified

4245 /// \retval INT_MAX for infinity
4246 /// \exception FE_INVALID for 0 or infinite values
4247 inline int ilogb(half arg)
4248 {
4249 int abs = arg.data_ & 0x7FFF, exp;
4250 if(!abs || abs >= 0x7C00)
4251 {
4252 detail::raise(FE_INVALID);
4253 return !abs ? FP_ILOGB0 : (abs==0x7C00) ? INT_MAX : FP_ILOGBNAN;
4254 }
4255 for(exp=(abs>>10)-15; abs<0x200; abs<<=1,--exp) ;
4256 return exp;
4257 }
4258
4259 /// Extract exponent.
4260 /// **See also:** Documentation for [std::logb](https://en.cppreference.com/w/cpp/numeric/math/logb).

Callers

nothing calls this directly

Calls 1

raiseFunction · 0.85

Tested by

no test coverage detected