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

Function operator/

include/half.hpp:2650–2677  ·  view source on GitHub ↗

Division. This operation is exact to rounding for all rounding modes. \param x left operand \param y right operand \return quotient of half expressions \exception FE_INVALID if dividing 0s or infinities with each other or if \a x or \a y is signaling NaN \exception FE_DIVBYZERO if dividing finite value by 0 \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding

Source from the content-addressed store, hash-verified

2648 /// \exception FE_DIVBYZERO if dividing finite value by 0
2649 /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
2650 inline half operator/(half x, half y)
2651 {
2652 #ifdef HALF_ARITHMETIC_TYPE
2653 return half(detail::binary, detail::float2half<half::round_style>(detail::half2float<detail::internal_t>(x.data_)/detail::half2float<detail::internal_t>(y.data_)));
2654 #else
2655 int absx = x.data_ & 0x7FFF, absy = y.data_ & 0x7FFF, exp = 14;
2656 unsigned int sign = (x.data_^y.data_) & 0x8000;
2657 if(absx >= 0x7C00 || absy >= 0x7C00)
2658 return half(detail::binary, (absx>0x7C00 || absy>0x7C00) ? detail::signal(x.data_, y.data_) :
2659 (absx==absy) ? detail::invalid() : (sign|((absx==0x7C00) ? 0x7C00 : 0)));
2660 if(!absx)
2661 return half(detail::binary, absy ? sign : detail::invalid());
2662 if(!absy)
2663 return half(detail::binary, detail::pole(sign));
2664 for(; absx<0x400; absx<<=1,--exp) ;
2665 for(; absy<0x400; absy<<=1,++exp) ;
2666 detail::uint32 mx = (absx&0x3FF) | 0x400, my = (absy&0x3FF) | 0x400;
2667 int i = mx < my;
2668 exp += (absx>>10) - (absy>>10) - i;
2669 if(exp > 29)
2670 return half(detail::binary, detail::overflow<half::round_style>(sign));
2671 else if(exp < -11)
2672 return half(detail::binary, detail::underflow<half::round_style>(sign));
2673 mx <<= 12 + i;
2674 my <<= 1;
2675 return half(detail::binary, detail::fixed2half<half::round_style,11,false,false,false>(mx/my, exp, sign, mx%my!=0));
2676 #endif
2677 }
2678
2679 /// \}
2680 /// \anchor streaming

Callers

nothing calls this directly

Calls 4

halfClass · 0.85
signalFunction · 0.85
invalidFunction · 0.85
poleFunction · 0.85

Tested by

no test coverage detected