MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / nextafter

Method nextafter

dnn/include/megdnn/dtype/half.hpp:1750–1762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1748 /// \param to direction to enumerate into
1749 /// \return next representable number
1750 MEGDNN_HOST MEGDNN_DEVICE static half nextafter(half from, half to)
1751 {
1752 uint16 fabs = from.data_ & 0x7FFF, tabs = to.data_ & 0x7FFF;
1753 if(fabs > 0x7C00)
1754 return from;
1755 if(tabs > 0x7C00 || from.data_ == to.data_ || !(fabs|tabs))
1756 return to;
1757 if(!fabs)
1758 return half(binary_t(), (to.data_&0x8000)+1);
1759 bool lt = (signbit(from) ? (static_cast<int17>(0x8000)-from.data_) : static_cast<int17>(from.data_)) <
1760 (signbit(to) ? (static_cast<int17>(0x8000)-to.data_) : static_cast<int17>(to.data_));
1761 return half(binary_t(), from.data_+(((from.data_>>15)^static_cast<uint16>(lt))<<1)-1);
1762 }
1763
1764 /// Sign implementation
1765 /// \param x first operand

Callers

nothing calls this directly

Calls 3

halfClass · 0.85
binary_tClass · 0.70
signbitFunction · 0.70

Tested by

no test coverage detected