📄 sc_fix.h
字号:
sc_fix::sc_fix( tp a, \ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ SC_TC_, \ sc_fxcast_switch(), \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ a.type_params(), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ int wl_, int iwl_, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( a.type_params(), wl_, iwl_ ), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ sc_q_mode qm, sc_o_mode om, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( a.type_params(), qm, om ), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ sc_q_mode qm, sc_o_mode om, int nb, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( a.type_params(), qm, om, nb ), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( wl_, iwl_, qm, om ), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ sc_fxtype_params( wl_, iwl_, qm, om, nb ), \ SC_TC_, \ cast_sw, \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ const sc_fxtype_params& type_params, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ type_params, \ SC_TC_, \ sc_fxcast_switch(), \ observer_ ) \{} \ \inline \sc_fix::sc_fix( tp a, \ const sc_fxtype_params& type_params, \ const sc_fxcast_switch& cast_sw, \ sc_fxnum_observer* observer_ ) \: sc_fxnum( a, \ type_params, \ SC_TC_, \ cast_sw, \ observer_ ) \{}DEFN_CTORS_T_A(int)DEFN_CTORS_T_A(unsigned int)DEFN_CTORS_T_A(long)DEFN_CTORS_T_A(unsigned long)DEFN_CTORS_T_A(double)DEFN_CTORS_T_A(const char*)DEFN_CTORS_T_A(const sc_fxval&)DEFN_CTORS_T_A(const sc_fxval_fast&)DEFN_CTORS_T_B(const sc_fxnum&)DEFN_CTORS_T_B(const sc_fxnum_fast&)#ifndef SC_FX_EXCLUDE_OTHERDEFN_CTORS_T_A(int64)DEFN_CTORS_T_A(uint64)DEFN_CTORS_T_A(const sc_int_base&)DEFN_CTORS_T_A(const sc_uint_base&)DEFN_CTORS_T_A(const sc_signed&)DEFN_CTORS_T_A(const sc_unsigned&)#endif#undef DEFN_CTORS_T_A#undef DEFN_CTORS_T_B// copy constructorinlinesc_fix::sc_fix( const sc_fix& a ): sc_fxnum( a, a.type_params(), SC_TC_, sc_fxcast_switch(), 0 ){}// unary bitwise operatorsinlineconst sc_fixsc_fix::operator ~ () const{ SC_FXNUM_OBSERVER_READ_( *this ) int iwl_c = iwl(); int wl_c = wl(); sc_fix c( wl_c, iwl_c ); for( int i = iwl_c - wl_c; i < iwl_c; ++ i ) c.set_bit( i, ! get_bit( i ) ); return sc_fix( c, wl_c, iwl_c );}// unary bitwise functionsinlinevoidb_not( sc_fix& c, const sc_fix& a ){ SC_FXNUM_OBSERVER_READ_( a ) int iwl_c = c.iwl(); for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) c.set_bit( i, ! a.get_bit( i ) ); c.cast(); SC_FXNUM_OBSERVER_WRITE_( c )}// binary bitwise operators#define DEFN_BIN_OP_T(op,op2,tp1,tp2) \inline \const sc_fix \operator op ( const tp1& a, const tp2& b ) \{ \ a.observer_read(); \ b.observer_read(); \ int iwl_a = a.iwl(); \ int iwl_b = b.iwl(); \ int iwl_c = sc_max( iwl_a, iwl_b ); \ int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b ); \ sc_fix c( iwl_c + fwl_c, iwl_c ); \ for( int i = -fwl_c; i < iwl_c; ++ i ) \ c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ return sc_fix( c, iwl_c + fwl_c, iwl_c ); \}DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix)DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix_fast)DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix)DEFN_BIN_OP_T(|,||,sc_fix,sc_fix)DEFN_BIN_OP_T(|,||,sc_fix,sc_fix_fast)DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix)DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix)DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix_fast)DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix)#undef DEFN_BIN_OP_T// binary bitwise functions#define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2) \inline \void \fnc ( sc_fix& c, const tp1& a, const tp2& b ) \{ \ a.observer_read(); \ b.observer_read(); \ int iwl_c = c.iwl(); \ for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) \ c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \ c.cast(); \ SC_FXNUM_OBSERVER_WRITE_( c ) \}DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix)DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix_fast)DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix)DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix)DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix_fast)DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix)DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix)DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix_fast)DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix)#undef DEFN_BIN_FNC_T// assignment operatorsinlinesc_fix&sc_fix::operator = ( const sc_fix& a ){ sc_fxnum::operator = ( a ); return *this;}#define DEFN_ASN_OP_T(op,tp) \inline \sc_fix& \sc_fix::operator op ( tp a ) \{ \ sc_fxnum::operator op( a ); \ return *this; \}#ifndef SC_FX_EXCLUDE_OTHER#define DEFN_ASN_OP_OTHER(op) \DEFN_ASN_OP_T(op,int64) \DEFN_ASN_OP_T(op,uint64) \DEFN_ASN_OP_T(op,const sc_int_base&) \DEFN_ASN_OP_T(op,const sc_uint_base&) \DEFN_ASN_OP_T(op,const sc_signed&) \DEFN_ASN_OP_T(op,const sc_unsigned&)#else#define DEFN_ASN_OP_OTHER(op)#endif#define DEFN_ASN_OP(op) \DEFN_ASN_OP_T(op,int) \DEFN_ASN_OP_T(op,unsigned int) \DEFN_ASN_OP_T(op,long) \DEFN_ASN_OP_T(op,unsigned long) \DEFN_ASN_OP_T(op,double) \DEFN_ASN_OP_T(op,const char*) \DEFN_ASN_OP_T(op,const sc_fxval&) \DEFN_ASN_OP_T(op,const sc_fxval_fast&) \DEFN_ASN_OP_T(op,const sc_fxnum&) \DEFN_ASN_OP_T(op,const sc_fxnum_fast&) \DEFN_ASN_OP_OTHER(op)DEFN_ASN_OP(=)DEFN_ASN_OP(*=)DEFN_ASN_OP(/=)DEFN_ASN_OP(+=)DEFN_ASN_OP(-=)DEFN_ASN_OP_T(<<=,int)DEFN_ASN_OP_T(>>=,int)#undef DEFN_ASN_OP_T#undef DEFN_ASN_OP_OTHER#undef DEFN_ASN_OP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -