64#ifdef SC_FXVAL_IMPLICIT_CONV
65# define SCFX_EXPLICIT_
67# define SCFX_EXPLICIT_ explicit
69#ifdef SC_FXVAL_IMPLICIT_OTHER
70# define SCFX_EXPLICIT_OTHER_
72# define SCFX_EXPLICIT_OTHER_ explicit
148#define DECL_BIN_OP_T(op,tp) \
149 friend sc_fxval operator op ( const sc_fxval&, tp ); \
150 friend sc_fxval operator op ( tp, const sc_fxval& );
152#define DECL_BIN_OP_OTHER(op) \
153 DECL_BIN_OP_T(op,int64) \
154 DECL_BIN_OP_T(op,uint64) \
155 DECL_BIN_OP_T(op,const sc_int_base&) \
156 DECL_BIN_OP_T(op,const sc_uint_base&) \
157 DECL_BIN_OP_T(op,const sc_signed&) \
158 DECL_BIN_OP_T(op,const sc_unsigned&)
160#define DECL_BIN_OP(op,dummy) \
161 friend sc_fxval operator op ( const sc_fxval&, const sc_fxval& ); \
162 DECL_BIN_OP_T(op,int) \
163 DECL_BIN_OP_T(op,unsigned int) \
164 DECL_BIN_OP_T(op,long) \
165 DECL_BIN_OP_T(op,unsigned long) \
166 DECL_BIN_OP_T(op,float) \
167 DECL_BIN_OP_T(op,double) \
168 DECL_BIN_OP_T(op,const char*) \
169 DECL_BIN_OP_T(op,const sc_fxval_fast&) \
170 DECL_BIN_OP_T(op,const sc_fxnum_fast&) \
171 DECL_BIN_OP_OTHER(op)
199#undef DECL_BIN_OP_OTHER
208#define DECL_BIN_FNC_T(fnc,tp) \
209 friend void fnc ( sc_fxval&, const sc_fxval&, tp ); \
210 friend void fnc ( sc_fxval&, tp, const sc_fxval& );
212#define DECL_BIN_FNC_OTHER(fnc) \
213 DECL_BIN_FNC_T(fnc,int64) \
214 DECL_BIN_FNC_T(fnc,uint64) \
215 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
216 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
217 DECL_BIN_FNC_T(fnc,const sc_signed&) \
218 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
220#define DECL_BIN_FNC(fnc) \
221 friend void fnc ( sc_fxval&, const sc_fxval&, const sc_fxval& ); \
222 DECL_BIN_FNC_T(fnc,int) \
223 DECL_BIN_FNC_T(fnc,unsigned int) \
224 DECL_BIN_FNC_T(fnc,long) \
225 DECL_BIN_FNC_T(fnc,unsigned long) \
226 DECL_BIN_FNC_T(fnc,float) \
227 DECL_BIN_FNC_T(fnc,double) \
228 DECL_BIN_FNC_T(fnc,const char*) \
229 DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \
230 DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&) \
231 DECL_BIN_FNC_OTHER(fnc)
239#undef DECL_BIN_FNC_OTHER
248#define DECL_REL_OP_T(op,tp) \
249 friend bool operator op ( const sc_fxval&, tp ); \
250 friend bool operator op ( tp, const sc_fxval& );
252#define DECL_REL_OP_OTHER(op) \
253 DECL_REL_OP_T(op,int64) \
254 DECL_REL_OP_T(op,uint64) \
255 DECL_REL_OP_T(op,const sc_int_base&) \
256 DECL_REL_OP_T(op,const sc_uint_base&) \
257 DECL_REL_OP_T(op,const sc_signed&) \
258 DECL_REL_OP_T(op,const sc_unsigned&)
260#define DECL_REL_OP(op) \
261 friend bool operator op ( const sc_fxval&, const sc_fxval& ); \
262 DECL_REL_OP_T(op,int) \
263 DECL_REL_OP_T(op,unsigned int) \
264 DECL_REL_OP_T(op,long) \
265 DECL_REL_OP_T(op,unsigned long) \
266 DECL_REL_OP_T(op,float) \
267 DECL_REL_OP_T(op,double) \
268 DECL_REL_OP_T(op,const char*) \
269 DECL_REL_OP_T(op,const sc_fxval_fast&) \
270 DECL_REL_OP_T(op,const sc_fxnum_fast&) \
271 DECL_REL_OP_OTHER(op)
281#undef DECL_REL_OP_OTHER
287#define DECL_ASN_OP_T(op,tp) \
288 sc_fxval& operator op( tp );
290#define DECL_ASN_OP_OTHER(op) \
291 DECL_ASN_OP_T(op,int64) \
292 DECL_ASN_OP_T(op,uint64) \
293 DECL_ASN_OP_T(op,const sc_int_base&) \
294 DECL_ASN_OP_T(op,const sc_uint_base&) \
295 DECL_ASN_OP_T(op,const sc_signed&) \
296 DECL_ASN_OP_T(op,const sc_unsigned&)
298#define DECL_ASN_OP(op) \
299 DECL_ASN_OP_T(op,int) \
300 DECL_ASN_OP_T(op,unsigned int) \
301 DECL_ASN_OP_T(op,long) \
302 DECL_ASN_OP_T(op,unsigned long) \
303 DECL_ASN_OP_T(op,float) \
304 DECL_ASN_OP_T(op,double) \
305 DECL_ASN_OP_T(op,const char*) \
306 DECL_ASN_OP_T(op,const sc_fxval&) \
307 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
308 DECL_ASN_OP_T(op,const sc_fxnum&) \
309 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
310 DECL_ASN_OP_OTHER(op)
323#undef DECL_ASN_OP_OTHER
338 operator double()
const;
343 short to_short()
const;
344 unsigned short to_ushort()
const;
346 unsigned int to_uint()
const;
347 long to_long()
const;
348 unsigned long to_ulong()
const;
349 int64 to_int64()
const;
351 float to_float()
const;
352 double to_double()
const;
373 bool is_zero()
const;
376 bool is_normal()
const;
378 bool rounding_flag()
const;
383 void print( ::std::ostream& = ::std::cout )
const;
384 void scan( ::std::istream& = ::std::cin );
385 void dump( ::std::ostream& = ::std::cout )
const;
389 bool get_bit(
int )
const;
397 void get_type(
int&,
int&,
sc_enc& )
const;
450 double get_val()
const;
451 void set_val(
double );
467#define DECL_BIN_OP_T(op,tp) \
468 friend sc_fxval_fast operator op ( const sc_fxval_fast&, tp ); \
469 friend sc_fxval_fast operator op ( tp, const sc_fxval_fast& );
471#define DECL_BIN_OP_OTHER(op) \
472 DECL_BIN_OP_T(op,int64) \
473 DECL_BIN_OP_T(op,uint64) \
474 DECL_BIN_OP_T(op,const sc_int_base&) \
475 DECL_BIN_OP_T(op,const sc_uint_base&) \
476 DECL_BIN_OP_T(op,const sc_signed&) \
477 DECL_BIN_OP_T(op,const sc_unsigned&)
479#define DECL_BIN_OP(op,dummy) \
480 friend sc_fxval_fast operator op ( const sc_fxval_fast&, \
481 const sc_fxval_fast& ); \
482 DECL_BIN_OP_T(op,int) \
483 DECL_BIN_OP_T(op,unsigned int) \
484 DECL_BIN_OP_T(op,long) \
485 DECL_BIN_OP_T(op,unsigned long) \
486 DECL_BIN_OP_T(op,float) \
487 DECL_BIN_OP_T(op,double) \
488 DECL_BIN_OP_T(op,const char*) \
489 DECL_BIN_OP_OTHER(op)
496 friend sc_fxval_fast
operator / (
const sc_fxval_fast&,
497 const sc_fxval_fast& );
514#undef DECL_BIN_OP_OTHER
523#define DECL_BIN_FNC_T(fnc,tp) \
524 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, tp ); \
525 friend void fnc ( sc_fxval_fast&, tp, const sc_fxval_fast& );
527#define DECL_BIN_FNC_OTHER(fnc) \
528 DECL_BIN_FNC_T(fnc,int64) \
529 DECL_BIN_FNC_T(fnc,uint64) \
530 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
531 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
532 DECL_BIN_FNC_T(fnc,const sc_signed&) \
533 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
535#define DECL_BIN_FNC(fnc) \
536 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, \
537 const sc_fxval_fast& ); \
538 DECL_BIN_FNC_T(fnc,int) \
539 DECL_BIN_FNC_T(fnc,unsigned int) \
540 DECL_BIN_FNC_T(fnc,long) \
541 DECL_BIN_FNC_T(fnc,unsigned long) \
542 DECL_BIN_FNC_T(fnc,float) \
543 DECL_BIN_FNC_T(fnc,double) \
544 DECL_BIN_FNC_T(fnc,const char*) \
545 DECL_BIN_FNC_T(fnc,const sc_fxval&) \
546 DECL_BIN_FNC_T(fnc,const sc_fxnum&) \
547 DECL_BIN_FNC_OTHER(fnc)
555#undef DECL_BIN_FNC_OTHER
558 friend void lshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
559 friend void rshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
564#define DECL_REL_OP_T(op,tp) \
565 friend bool operator op ( const sc_fxval_fast&, tp ); \
566 friend bool operator op ( tp, const sc_fxval_fast& );
568#define DECL_REL_OP_OTHER(op) \
569 DECL_REL_OP_T(op,int64) \
570 DECL_REL_OP_T(op,uint64) \
571 DECL_REL_OP_T(op,const sc_int_base&) \
572 DECL_REL_OP_T(op,const sc_uint_base&) \
573 DECL_REL_OP_T(op,const sc_signed&) \
574 DECL_REL_OP_T(op,const sc_unsigned&)
576#define DECL_REL_OP(op) \
577 friend bool operator op ( const sc_fxval_fast&, const sc_fxval_fast& ); \
578 DECL_REL_OP_T(op,int) \
579 DECL_REL_OP_T(op,unsigned int) \
580 DECL_REL_OP_T(op,long) \
581 DECL_REL_OP_T(op,unsigned long) \
582 DECL_REL_OP_T(op,float) \
583 DECL_REL_OP_T(op,double) \
584 DECL_REL_OP_T(op,const char*) \
585 DECL_REL_OP_OTHER(op)
595#undef DECL_REL_OP_OTHER
601#define DECL_ASN_OP_T(op,tp) \
602 sc_fxval_fast& operator op( tp );
604#define DECL_ASN_OP_OTHER(op) \
605 DECL_ASN_OP_T(op,int64) \
606 DECL_ASN_OP_T(op,uint64) \
607 DECL_ASN_OP_T(op,const sc_int_base&) \
608 DECL_ASN_OP_T(op,const sc_uint_base&) \
609 DECL_ASN_OP_T(op,const sc_signed&) \
610 DECL_ASN_OP_T(op,const sc_unsigned&)
612#define DECL_ASN_OP(op) \
613 DECL_ASN_OP_T(op,int) \
614 DECL_ASN_OP_T(op,unsigned int) \
615 DECL_ASN_OP_T(op,long) \
616 DECL_ASN_OP_T(op,unsigned long) \
617 DECL_ASN_OP_T(op,float) \
618 DECL_ASN_OP_T(op,double) \
619 DECL_ASN_OP_T(op,const char*) \
620 DECL_ASN_OP_T(op,const sc_fxval&) \
621 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
622 DECL_ASN_OP_T(op,const sc_fxnum&) \
623 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
624 DECL_ASN_OP_OTHER(op)
637#undef DECL_ASN_OP_OTHER
643 sc_fxval_fast operator ++ (
int );
644 sc_fxval_fast operator -- (
int );
646 sc_fxval_fast& operator ++ ();
647 sc_fxval_fast& operator -- ();
652 operator double()
const;
657 short to_short()
const;
658 unsigned short to_ushort()
const;
660 unsigned int to_uint()
const;
661 long to_long()
const;
662 unsigned long to_ulong()
const;
663 int64 to_int64()
const;
665 float to_float()
const;
666 double to_double()
const;
687 bool is_zero()
const;
690 bool is_normal()
const;
692 bool rounding_flag()
const;
697 void print( ::std::ostream& = ::std::cout )
const;
698 void scan( ::std::istream& = ::std::cin );
699 void dump( ::std::ostream& = ::std::cout )
const;
743: m_rep( a != 0 ? a : new
scfx_rep ),
753 m_observer( observer_ )
763 m_observer( observer_ )
771#define DEFN_CTOR_T(tp,arg) \
773sc_fxval::sc_fxval( tp a, \
774 sc_fxval_observer* observer_ ) \
775: m_rep( new scfx_rep( arg ) ), \
776 m_observer( observer_ ) \
778 SC_FXVAL_OBSERVER_DEFAULT_ \
779 SC_FXVAL_OBSERVER_CONSTRUCT_( *this ) \
780 SC_FXVAL_OBSERVER_WRITE_( *this ) \
783#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a)
784#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,a.to_double())
785#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.value())
870#define DEFN_BIN_OP_T(op,fnc,tp) \
873operator op ( const sc_fxval& a, tp b ) \
875 SC_FXVAL_OBSERVER_READ_( a ) \
877 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) ); \
882operator op ( tp a, const sc_fxval& b ) \
884 SC_FXVAL_OBSERVER_READ_( b ) \
886 return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) ); \
889#define DEFN_BIN_OP_OTHER(op,fnc) \
890DEFN_BIN_OP_T(op,fnc,int64) \
891DEFN_BIN_OP_T(op,fnc,uint64) \
892DEFN_BIN_OP_T(op,fnc,const sc_int_base&) \
893DEFN_BIN_OP_T(op,fnc,const sc_uint_base&) \
894DEFN_BIN_OP_T(op,fnc,const sc_signed&) \
895DEFN_BIN_OP_T(op,fnc,const sc_unsigned&)
897#define DEFN_BIN_OP(op,fnc) \
900operator op ( const sc_fxval& a, const sc_fxval& b ) \
902 SC_FXVAL_OBSERVER_READ_( a ) \
903 SC_FXVAL_OBSERVER_READ_( b ) \
904 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \
907DEFN_BIN_OP_T(op,fnc,int) \
908DEFN_BIN_OP_T(op,fnc,unsigned int) \
909DEFN_BIN_OP_T(op,fnc,long) \
910DEFN_BIN_OP_T(op,fnc,unsigned long) \
911DEFN_BIN_OP_T(op,fnc,float) \
912DEFN_BIN_OP_T(op,fnc,double) \
913DEFN_BIN_OP_T(op,fnc,const char*) \
914DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&) \
915DEFN_BIN_OP_OTHER(op,fnc)
948#undef DEFN_BIN_OP_OTHER
971#define DEFN_BIN_FNC_T(fnc,tp) \
974fnc ( sc_fxval& c, const sc_fxval& a, tp b ) \
976 SC_FXVAL_OBSERVER_READ_( a ) \
979 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ); \
980 SC_FXVAL_OBSERVER_WRITE_( c ) \
985fnc ( sc_fxval& c, tp a, const sc_fxval& b ) \
987 SC_FXVAL_OBSERVER_READ_( b ) \
990 c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ); \
991 SC_FXVAL_OBSERVER_WRITE_( c ) \
994#define DEFN_BIN_FNC_OTHER(fnc) \
995DEFN_BIN_FNC_T(fnc,int64) \
996DEFN_BIN_FNC_T(fnc,uint64) \
997DEFN_BIN_FNC_T(fnc,const sc_int_base&) \
998DEFN_BIN_FNC_T(fnc,const sc_uint_base&) \
999DEFN_BIN_FNC_T(fnc,const sc_signed&) \
1000DEFN_BIN_FNC_T(fnc,const sc_unsigned&)
1002#define DEFN_BIN_FNC(fnc) \
1005fnc( sc_fxval& c, const sc_fxval& a, const sc_fxval& b ) \
1007 SC_FXVAL_OBSERVER_READ_( a ) \
1008 SC_FXVAL_OBSERVER_READ_( b ) \
1010 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ); \
1011 SC_FXVAL_OBSERVER_WRITE_( c ) \
1014DEFN_BIN_FNC_T(fnc,int) \
1015DEFN_BIN_FNC_T(fnc,unsigned int) \
1016DEFN_BIN_FNC_T(fnc,long) \
1017DEFN_BIN_FNC_T(fnc,unsigned long) \
1018DEFN_BIN_FNC_T(fnc,float) \
1019DEFN_BIN_FNC_T(fnc,double) \
1020DEFN_BIN_FNC_T(fnc,const char*) \
1021DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&) \
1022DEFN_BIN_FNC_OTHER(fnc)
1029#undef DEFN_BIN_FNC_T
1030#undef DEFN_BIN_FNC_OTHER
1057#define DEFN_REL_OP_T(op,ret,tp) \
1060operator op ( const sc_fxval& a, tp b ) \
1062 SC_FXVAL_OBSERVER_READ_( a ) \
1063 sc_fxval tmp( b ); \
1064 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep ); \
1070operator op ( tp a, const sc_fxval& b ) \
1072 SC_FXVAL_OBSERVER_READ_( b ) \
1073 sc_fxval tmp( a ); \
1074 int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep ); \
1078#define DEFN_REL_OP_OTHER(op,ret) \
1079DEFN_REL_OP_T(op,ret,int64) \
1080DEFN_REL_OP_T(op,ret,uint64) \
1081DEFN_REL_OP_T(op,ret,const sc_int_base&) \
1082DEFN_REL_OP_T(op,ret,const sc_uint_base&) \
1083DEFN_REL_OP_T(op,ret,const sc_signed&) \
1084DEFN_REL_OP_T(op,ret,const sc_unsigned&)
1086#define DEFN_REL_OP(op,ret) \
1089operator op ( const sc_fxval& a, const sc_fxval& b) \
1091 SC_FXVAL_OBSERVER_READ_( a ) \
1092 SC_FXVAL_OBSERVER_READ_( b ) \
1093 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep ); \
1097DEFN_REL_OP_T(op,ret,int) \
1098DEFN_REL_OP_T(op,ret,unsigned int) \
1099DEFN_REL_OP_T(op,ret,long) \
1100DEFN_REL_OP_T(op,ret,unsigned long) \
1101DEFN_REL_OP_T(op,ret,float) \
1102DEFN_REL_OP_T(op,ret,double) \
1103DEFN_REL_OP_T(op,ret,const char*) \
1104DEFN_REL_OP_T(op,ret,const sc_fxval_fast&) \
1105DEFN_REL_OP_OTHER(op,ret)
1115#undef DEFN_REL_OP_OTHER
1123sc_fxval::operator = (
const sc_fxval& a )
1134#define DEFN_ASN_OP_T(tp) \
1137sc_fxval::operator = ( tp b ) \
1139 sc_fxval tmp( b ); \
1140 *m_rep = *tmp.m_rep; \
1141 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1163#define DEFN_ASN_OP_T(op,fnc,tp) \
1166sc_fxval::operator op ( tp b ) \
1168 SC_FXVAL_OBSERVER_READ_( *this ) \
1169 sc_fxval tmp( b ); \
1170 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep ); \
1173 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1177#define DEFN_ASN_OP_OTHER(op,fnc) \
1178DEFN_ASN_OP_T(op,fnc,int64) \
1179DEFN_ASN_OP_T(op,fnc,uint64) \
1180DEFN_ASN_OP_T(op,fnc,const sc_int_base&) \
1181DEFN_ASN_OP_T(op,fnc,const sc_uint_base&) \
1182DEFN_ASN_OP_T(op,fnc,const sc_signed&) \
1183DEFN_ASN_OP_T(op,fnc,const sc_unsigned&)
1185#define DEFN_ASN_OP(op,fnc) \
1188sc_fxval::operator op ( const sc_fxval& b ) \
1190 SC_FXVAL_OBSERVER_READ_( *this ) \
1191 SC_FXVAL_OBSERVER_READ_( b ) \
1192 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep ); \
1195 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1199DEFN_ASN_OP_T(op,fnc,int) \
1200DEFN_ASN_OP_T(op,fnc,unsigned int) \
1201DEFN_ASN_OP_T(op,fnc,long) \
1202DEFN_ASN_OP_T(op,fnc,unsigned long) \
1203DEFN_ASN_OP_T(op,fnc,float) \
1204DEFN_ASN_OP_T(op,fnc,double) \
1205DEFN_ASN_OP_T(op,fnc,const char*) \
1206DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&) \
1207DEFN_ASN_OP_OTHER(op,fnc)
1215#undef DEFN_ASN_OP_OTHER
1221sc_fxval::operator <<= (
int b )
1280sc_fxval::operator double()
const
1294 return static_cast<short>( m_rep->
to_uint64() );
1302 return static_cast<unsigned short>( m_rep->
to_uint64() );
1310 return static_cast<int>( m_rep->
to_uint64() );
1326 return static_cast<unsigned int>( m_rep->
to_uint64() );
1342 return static_cast<long>( m_rep->
to_uint64() );
1350 return static_cast<unsigned long>( m_rep->
to_uint64() );
1358 return static_cast<float>( m_rep->
to_double() );
1481sc_fxval_fast_observer*
1493 m_observer( observer_ )
1503 m_observer( observer_ )
1511#define DEFN_CTOR_T(tp,arg) \
1513sc_fxval_fast::sc_fxval_fast( tp a, \
1514 sc_fxval_fast_observer* observer_ ) \
1516 m_observer( observer_ ) \
1518 SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
1519 SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this ) \
1520 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1523#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a ))
1524#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,from_string( a ))
1525#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
1602 c.m_val = - a.m_val;
1609#define DEFN_BIN_OP_T(op,tp) \
1612operator op ( const sc_fxval_fast& a, tp b ) \
1614 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1615 sc_fxval_fast tmp( b ); \
1616 return sc_fxval_fast( a.m_val op tmp.m_val ); \
1621operator op ( tp a, const sc_fxval_fast& b ) \
1623 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1624 sc_fxval_fast tmp( a ); \
1625 return sc_fxval_fast( tmp.m_val op b.m_val ); \
1628#define DEFN_BIN_OP_OTHER(op) \
1629DEFN_BIN_OP_T(op,int64) \
1630DEFN_BIN_OP_T(op,uint64) \
1631DEFN_BIN_OP_T(op,const sc_int_base&) \
1632DEFN_BIN_OP_T(op,const sc_uint_base&) \
1633DEFN_BIN_OP_T(op,const sc_signed&) \
1634DEFN_BIN_OP_T(op,const sc_unsigned&)
1636#define DEFN_BIN_OP(op,dummy) \
1639operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1641 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1642 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1643 return sc_fxval_fast( a.m_val op b.m_val ); \
1646DEFN_BIN_OP_T(op,int) \
1647DEFN_BIN_OP_T(op,unsigned int) \
1648DEFN_BIN_OP_T(op,long) \
1649DEFN_BIN_OP_T(op,unsigned long) \
1650DEFN_BIN_OP_T(op,float) \
1651DEFN_BIN_OP_T(op,double) \
1652DEFN_BIN_OP_T(op,const char*) \
1653DEFN_BIN_OP_OTHER(op)
1685#undef DEFN_BIN_OP_OTHER
1708#define DEFN_BIN_FNC_T(fnc,op,tp) \
1711fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b ) \
1713 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1714 sc_fxval_fast tmp( b ); \
1715 c.m_val = a.m_val op tmp.m_val; \
1716 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1721fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b ) \
1723 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1724 sc_fxval_fast tmp( a ); \
1725 c.m_val = tmp.m_val op b.m_val; \
1726 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1729#define DEFN_BIN_FNC_OTHER(fnc,op) \
1730DEFN_BIN_FNC_T(fnc,op,int64) \
1731DEFN_BIN_FNC_T(fnc,op,uint64) \
1732DEFN_BIN_FNC_T(fnc,op,const sc_int_base&) \
1733DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&) \
1734DEFN_BIN_FNC_T(fnc,op,const sc_signed&) \
1735DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&)
1737#define DEFN_BIN_FNC(fnc,op) \
1740fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1742 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1743 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1744 c.m_val = a.m_val op b.m_val; \
1745 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1748DEFN_BIN_FNC_T(fnc,op,int) \
1749DEFN_BIN_FNC_T(fnc,op,unsigned int) \
1750DEFN_BIN_FNC_T(fnc,op,long) \
1751DEFN_BIN_FNC_T(fnc,op,unsigned long) \
1752DEFN_BIN_FNC_T(fnc,op,float) \
1753DEFN_BIN_FNC_T(fnc,op,double) \
1754DEFN_BIN_FNC_T(fnc,op,const char*) \
1755DEFN_BIN_FNC_OTHER(fnc,op)
1762#undef DEFN_BIN_FNC_T
1763#undef DEFN_BIN_FNC_OTHER
1788#define DEFN_REL_OP_T(op,tp) \
1791operator op ( const sc_fxval_fast& a, tp b ) \
1793 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1794 sc_fxval_fast tmp( b ); \
1795 return ( a.m_val op tmp.m_val ); \
1800operator op ( tp a, const sc_fxval_fast& b ) \
1802 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1803 sc_fxval_fast tmp( a ); \
1804 return ( tmp.m_val op b.m_val ); \
1807#define DEFN_REL_OP_OTHER(op) \
1808DEFN_REL_OP_T(op,int64) \
1809DEFN_REL_OP_T(op,uint64) \
1810DEFN_REL_OP_T(op,const sc_int_base&) \
1811DEFN_REL_OP_T(op,const sc_uint_base&) \
1812DEFN_REL_OP_T(op,const sc_signed&) \
1813DEFN_REL_OP_T(op,const sc_unsigned&)
1815#define DEFN_REL_OP(op) \
1818operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1820 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1821 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1822 return ( a.m_val op b.m_val ); \
1825DEFN_REL_OP_T(op,int) \
1826DEFN_REL_OP_T(op,unsigned int) \
1827DEFN_REL_OP_T(op,long) \
1828DEFN_REL_OP_T(op,unsigned long) \
1829DEFN_REL_OP_T(op,float) \
1830DEFN_REL_OP_T(op,double) \
1831DEFN_REL_OP_T(op,const char*) \
1832DEFN_REL_OP_OTHER(op)
1842#undef DEFN_REL_OP_OTHER
1850sc_fxval_fast::operator = (
const sc_fxval_fast& a )
1861#define DEFN_ASN_OP_T(tp) \
1864sc_fxval_fast::operator = ( tp a ) \
1866 sc_fxval_fast tmp( a ); \
1867 m_val = tmp.m_val; \
1868 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1890#define DEFN_ASN_OP_T(op,tp) \
1893sc_fxval_fast::operator op ( tp b ) \
1895 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
1896 sc_fxval_fast tmp( b ); \
1897 m_val op tmp.m_val; \
1898 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1902#define DEFN_ASN_OP_OTHER(op) \
1903DEFN_ASN_OP_T(op,int64) \
1904DEFN_ASN_OP_T(op,uint64) \
1905DEFN_ASN_OP_T(op,const sc_int_base&) \
1906DEFN_ASN_OP_T(op,const sc_uint_base&) \
1907DEFN_ASN_OP_T(op,const sc_signed&) \
1908DEFN_ASN_OP_T(op,const sc_unsigned&)
1910#define DEFN_ASN_OP(op) \
1913sc_fxval_fast::operator op ( const sc_fxval_fast& b ) \
1915 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
1916 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1918 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1922DEFN_ASN_OP_T(op,int) \
1923DEFN_ASN_OP_T(op,unsigned int) \
1924DEFN_ASN_OP_T(op,long) \
1925DEFN_ASN_OP_T(op,unsigned long) \
1926DEFN_ASN_OP_T(op,float) \
1927DEFN_ASN_OP_T(op,double) \
1928DEFN_ASN_OP_T(op,const char*) \
1929DEFN_ASN_OP_T(op,const sc_fxval&) \
1930DEFN_ASN_OP_OTHER(op)
1938#undef DEFN_ASN_OP_OTHER
1944sc_fxval_fast::operator <<= (
int b )
1954sc_fxval_fast::operator >>= (
int b )
2013sc_fxval_fast::operator double()
const
2027 return static_cast<short>(
to_uint64() );
2035 return static_cast<unsigned short>(
to_uint64() );
2059 return static_cast<unsigned int>(
to_uint64() );
2073 double mantissa_dbl = frexp(m_val, &exponent);
2078 if (!(-64 < exponent && exponent < 64))
2083 mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
2084 return mantissa_dbl >= 0 ? mantissa : -mantissa;
2092 return static_cast<long>(
to_uint64() );
2100 return static_cast<unsigned long>(
to_uint64() );
2108 return static_cast<float>( m_val );
2128 return (
id.negative() != 0 );
2137 return id.is_zero();
2195#undef SCFX_EXPLICIT_
2196#undef SCFX_EXPLICIT_OTHER_
#define DECL_BIN_FNC(fnc)
#define DECL_BIN_OP_T(op, tp)
#define DEFN_REL_OP(op, ret)
#define DEFN_BIN_FNC(fnc)
#define DEFN_BIN_OP(op, fnc)
#define DEFN_CTOR_T_B(tp)
#define DEFN_CTOR_T_C(tp)
#define DEFN_CTOR_T_A(tp)
#define DEFN_ASN_OP(op, fnc)
#define SCFX_EXPLICIT_OTHER_
#define DEFN_ASN_OP_T(tp)
#define DECL_ASN_OP_T(op, tp)
#define DECL_BIN_OP(op, dummy)
#define SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
#define SC_FXVAL_OBSERVER_READ_(object)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
void neg(sc_fxval &c, const sc_fxnum &a)
SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
const sc_big_op_info< WL, true, WR, true >::add_result operator+(const sc_bigint< WL > &left, const sc_bigint< WR > &right)
sc_fxval operator/(const sc_fxnum &a, const sc_fxnum &b)
unsigned long long uint64
const sc_big_op_info< WL, true, WR, true >::sub_result operator-(const sc_bigint< WL > &left, const sc_bigint< WR > &right)
SC_API scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
double scfx_pow2(int exp)
DEFN_BIN_OP_T(/, div, int64) DEFN_BIN_OP_T(/
inline::std::istream & operator>>(::std::istream &is, sc_bit &a)
SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
uint64 const sc_uint_base int b
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
constexpr uint64 UINT64_ONE
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
std::string to_dec() const
std::string to_bin() const
std::string to_hex() const
const scfx_rep * get_rep() const
SCFX_EXPLICIT_ sc_fxval(float, sc_fxval_observer *=0)
std::string to_string(sc_numrep, bool) const
std::string to_oct() const
sc_fxval quantization(const scfx_params &, bool &) const
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_int_base &, sc_fxval_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_signed &, sc_fxval_observer *=0)
std::string to_string(sc_numrep, sc_fmt) const
const sc_fxval & operator+() const
unsigned int to_uint() const
void scan(::std::istream &=::std::cin)
sc_fxval overflow(const scfx_params &, bool &) const
void unlock_observer(sc_fxval_observer *) const
SCFX_EXPLICIT_OTHER_ sc_fxval(int64, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(double, sc_fxval_observer *=0)
sc_fxval operator-() const
unsigned long to_ulong() const
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_uint_base &, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(unsigned long, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(long, sc_fxval_observer *=0)
std::string to_string() const
friend void lshift(sc_fxval &, const sc_fxval &, int)
sc_fxval_observer * lock_observer() const
std::string to_string(sc_fmt) const
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_unsigned &, sc_fxval_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval(uint64, sc_fxval_observer *=0)
friend sc_fxval operator>>(const sc_fxval &, int)
sc_fxval_observer * observer() const
void print(::std::ostream &=::std::cout) const
bool rounding_flag() const
unsigned short to_ushort() const
std::string to_string(sc_numrep, bool, sc_fmt) const
SCFX_EXPLICIT_ sc_fxval(unsigned int, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(const char *, sc_fxval_observer *=0)
void dump(::std::ostream &=::std::cout) const
std::string to_string(sc_numrep) const
void get_type(int &, int &, sc_enc &) const
friend void rshift(sc_fxval &, const sc_fxval &, int)
SCFX_EXPLICIT_ sc_fxval(int, sc_fxval_observer *=0)
sc_fxval(const sc_fxval_fast &, sc_fxval_observer *=0)
void print(::std::ostream &=::std::cout) const
std::string to_string(sc_numrep) const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_uint_base &, sc_fxval_fast_observer *=0)
std::string to_string(sc_numrep, sc_fmt) const
SCFX_EXPLICIT_ sc_fxval_fast(long, sc_fxval_fast_observer *=0)
sc_fxval_fast_observer * lock_observer() const
std::string to_string(sc_numrep, bool, sc_fmt) const
std::string to_string() const
static double from_string(const char *)
std::string to_string(sc_numrep, bool) const
void dump(::std::ostream &=::std::cout) const
std::string to_hex() const
SCFX_EXPLICIT_ sc_fxval_fast(int, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_signed &, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_ sc_fxval_fast(float, sc_fxval_fast_observer *=0)
sc_fxval_fast_observer * observer() const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(int64, sc_fxval_fast_observer *=0)
void scan(::std::istream &=::std::cin)
std::string to_string(sc_fmt) const
unsigned short to_ushort() const
unsigned long to_ulong() const
std::string to_oct() const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(uint64, sc_fxval_fast_observer *=0)
void unlock_observer(sc_fxval_fast_observer *) const
SCFX_EXPLICIT_ sc_fxval_fast(unsigned long, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_ sc_fxval_fast(double, sc_fxval_fast_observer *=0)
sc_fxval_fast(sc_fxval_fast_observer *=0)
std::string to_bin() const
const sc_fxval_fast & operator+() const
friend sc_fxval_fast operator>>(const sc_fxval_fast &, int)
std::string to_dec() const
bool rounding_flag() const
SCFX_EXPLICIT_ sc_fxval_fast(unsigned int, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_unsigned &, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_int_base &, sc_fxval_fast_observer *=0)
sc_fxval_fast & operator--()
unsigned int to_uint() const
sc_fxval_fast operator-() const
SCFX_EXPLICIT_ sc_fxval_fast(const char *, sc_fxval_fast_observer *=0)
sc_fxval_fast & operator++()
sc_fxval_fast(const sc_fxval &, sc_fxval_fast_observer *=0)
bool rounding_flag() const
void get_type(int &, int &, sc_enc &) const