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

Function raise

include/half.hpp:625–671  ·  view source on GitHub ↗

Raise floating-point exception. \param flags exceptions to raise \param cond condition to raise exceptions for

Source from the content-addressed store, hash-verified

623 /// \param flags exceptions to raise
624 /// \param cond condition to raise exceptions for
625 inline void raise(int HALF_UNUSED_NOERR(flags), bool HALF_UNUSED_NOERR(cond) = true)
626 {
627 #if HALF_ERRHANDLING
628 if(!cond)
629 return;
630 #if HALF_ERRHANDLING_FLAGS
631 errflags() |= flags;
632 #endif
633 #if HALF_ERRHANDLING_ERRNO
634 if(flags & FE_INVALID)
635 errno = EDOM;
636 else if(flags & (FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW))
637 errno = ERANGE;
638 #endif
639 #if HALF_ERRHANDLING_FENV && HALF_ENABLE_CPP11_CFENV
640 std::feraiseexcept(flags);
641 #endif
642 #ifdef HALF_ERRHANDLING_THROW_INVALID
643 if(flags & FE_INVALID)
644 throw std::domain_error(HALF_ERRHANDLING_THROW_INVALID);
645 #endif
646 #ifdef HALF_ERRHANDLING_THROW_DIVBYZERO
647 if(flags & FE_DIVBYZERO)
648 throw std::domain_error(HALF_ERRHANDLING_THROW_DIVBYZERO);
649 #endif
650 #ifdef HALF_ERRHANDLING_THROW_OVERFLOW
651 if(flags & FE_OVERFLOW)
652 throw std::overflow_error(HALF_ERRHANDLING_THROW_OVERFLOW);
653 #endif
654 #ifdef HALF_ERRHANDLING_THROW_UNDERFLOW
655 if(flags & FE_UNDERFLOW)
656 throw std::underflow_error(HALF_ERRHANDLING_THROW_UNDERFLOW);
657 #endif
658 #ifdef HALF_ERRHANDLING_THROW_INEXACT
659 if(flags & FE_INEXACT)
660 throw std::range_error(HALF_ERRHANDLING_THROW_INEXACT);
661 #endif
662 #if HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
663 if((flags & FE_UNDERFLOW) && !(flags & FE_INEXACT))
664 raise(FE_INEXACT);
665 #endif
666 #if HALF_ERRHANDLING_OVERFLOW_TO_INEXACT
667 if((flags & FE_OVERFLOW) && !(flags & FE_INEXACT))
668 raise(FE_INEXACT);
669 #endif
670 #endif
671 }
672
673 /// Check and signal for any NaN.
674 /// \param x first half-precision value to check

Callers 14

compsignalFunction · 0.85
signalFunction · 0.85
invalidFunction · 0.85
poleFunction · 0.85
check_underflowFunction · 0.85
overflowFunction · 0.85
underflowFunction · 0.85
roundedFunction · 0.85
integralFunction · 0.85
half2intFunction · 0.85
ilogbFunction · 0.85
nextafterFunction · 0.85

Calls 1

feraiseexceptFunction · 0.85

Tested by

no test coverage detected