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

Function rounded

include/half.hpp:820–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818 /// \exception FE_UNDERFLOW on underflows
819 /// \exception FE_INEXACT if value had to be rounded or \a I is `true`
820 template<std::float_round_style R,bool I> HALF_CONSTEXPR_NOERR unsigned int rounded(unsigned int value, int g, int s)
821 {
822 #if HALF_ERRHANDLING
823 value += (R==std::round_to_nearest) ? (g&(s|value)) :
824 (R==std::round_toward_infinity) ? (~(value>>15)&(g|s)) :
825 (R==std::round_toward_neg_infinity) ? ((value>>15)&(g|s)) : 0;
826 if((value&0x7C00) == 0x7C00)
827 raise(FE_OVERFLOW);
828 else if(value & 0x7C00)
829 raise(FE_INEXACT, I || (g|s)!=0);
830 else
831 raise(FE_UNDERFLOW, !(HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT) || I || (g|s)!=0);
832 return value;
833 #else
834 return (R==std::round_to_nearest) ? (value+(g&(s|value))) :
835 (R==std::round_toward_infinity) ? (value+(~(value>>15)&(g|s))) :
836 (R==std::round_toward_neg_infinity) ? (value+((value>>15)&(g|s))) :
837 value;
838 #endif
839 }
840
841 /// Round half-precision number to nearest integer value.
842 /// \tparam R rounding mode to use

Callers

nothing calls this directly

Calls 1

raiseFunction · 0.85

Tested by

no test coverage detected