#include "prcalc.h" _PRC_BOOL __test_negative(uint64_t val) { return (( val & 0b1000000000000000000000000000000000000000000000000000000000000000 ) == 0b1000000000000000000000000000000000000000000000000000000000000000) ; } _PRC_BOOL __test_overflow(uint64_t val1, uint64_t val2, uint64_t res, __PRC_OPERATION op) { if (op == ADD) { if ( __test_negative(val1) && __test_negative(val2) ) return !__test_negative( res ); else if ( (!__test_negative(val1)) && (!__test_negative(val2)) ) { return __test_negative( res ) ; } } else if (op == MUL) { if ( __test_negative(val1) && __test_negative(val2) ) return !( __test_negative( res ) ); else if ( (!__test_negative(val1)) && (!__test_negative(val2)) ) return !( __test_negative( res ) ); } return FALSE; }