MCPcopy Create free account
hub / github.com/apache/singa / modf

Function modf

include/half.hpp:4193–4211  ·  view source on GitHub ↗

Extract integer and fractional parts. See also:** Documentation for [std::modf](https://en.cppreference.com/w/cpp/numeric/math/modf). \param arg number to decompress \param iptr address to store integer part at \return fractional part \exception FE_INVALID for signaling NaN

Source from the content-addressed store, hash-verified

4191 /// \return fractional part
4192 /// \exception FE_INVALID for signaling NaN
4193 inline half modf(half arg, half *iptr)
4194 {
4195 unsigned int abs = arg.data_ & 0x7FFF;
4196 if(abs > 0x7C00)
4197 {
4198 arg = half(detail::binary, detail::signal(arg.data_));
4199 return *iptr = arg, arg;
4200 }
4201 if(abs >= 0x6400)
4202 return *iptr = arg, half(detail::binary, arg.data_&0x8000);
4203 if(abs < 0x3C00)
4204 return iptr->data_ = arg.data_ & 0x8000, arg;
4205 unsigned int exp = abs >> 10, mask = (1<<(25-exp)) - 1, m = arg.data_ & mask;
4206 iptr->data_ = arg.data_ & ~mask;
4207 if(!m)
4208 return half(detail::binary, arg.data_&0x8000);
4209 for(; m<0x400; m<<=1,--exp) ;
4210 return half(detail::binary, (arg.data_&0x8000)|(exp<<10)|(m&0x3FF));
4211 }
4212
4213 /// Extract exponent.
4214 /// **See also:** Documentation for [std::ilogb](https://en.cppreference.com/w/cpp/numeric/math/ilogb).

Callers 1

float2half_implFunction · 0.85

Calls 2

halfClass · 0.85
signalFunction · 0.85

Tested by

no test coverage detected