56 #ifndef SC_FX_EXCLUDE_OTHER
64 #ifdef SC_FXVAL_IMPLICIT_CONV
65 # define SCFX_EXPLICIT_ // nothing
67 # define SCFX_EXPLICIT_ explicit
69 #ifdef SC_FXVAL_IMPLICIT_OTHER
70 # define SCFX_EXPLICIT_OTHER_
72 # define SCFX_EXPLICIT_OTHER_ explicit
120 #ifndef SC_FX_EXCLUDE_OTHER
150 #define DECL_BIN_OP_T(op,tp) \
151 friend const sc_fxval operator op ( const sc_fxval&, tp ); \
152 friend const sc_fxval operator op ( tp, const sc_fxval& );
154 #ifndef SC_FX_EXCLUDE_OTHER
155 #define DECL_BIN_OP_OTHER(op) \
156 DECL_BIN_OP_T(op,int64) \
157 DECL_BIN_OP_T(op,uint64) \
158 DECL_BIN_OP_T(op,const sc_int_base&) \
159 DECL_BIN_OP_T(op,const sc_uint_base&) \
160 DECL_BIN_OP_T(op,const sc_signed&) \
161 DECL_BIN_OP_T(op,const sc_unsigned&)
163 #define DECL_BIN_OP_OTHER(op)
166 #define DECL_BIN_OP(op,dummy) \
167 friend const sc_fxval operator op ( const sc_fxval&, const sc_fxval& ); \
168 DECL_BIN_OP_T(op,int) \
169 DECL_BIN_OP_T(op,unsigned int) \
170 DECL_BIN_OP_T(op,long) \
171 DECL_BIN_OP_T(op,unsigned long) \
172 DECL_BIN_OP_T(op,float) \
173 DECL_BIN_OP_T(op,double) \
174 DECL_BIN_OP_T(op,const char*) \
175 DECL_BIN_OP_T(op,const sc_fxval_fast&) \
176 DECL_BIN_OP_T(op,const sc_fxnum_fast&) \
177 DECL_BIN_OP_OTHER(op)
188 DECL_BIN_OP_T(/,
long)
189 DECL_BIN_OP_T(/,
unsigned long)
190 DECL_BIN_OP_T(/,
float)
191 DECL_BIN_OP_T(/,
double)
192 DECL_BIN_OP_T(/,const
char*)
196 #ifndef SC_FX_EXCLUDE_OTHER
207 #undef DECL_BIN_OP_OTHER
211 friend const sc_fxval
operator >> (
const sc_fxval&,
int );
216 #define DECL_BIN_FNC_T(fnc,tp) \
217 friend void fnc ( sc_fxval&, const sc_fxval&, tp ); \
218 friend void fnc ( sc_fxval&, tp, const sc_fxval& );
220 #ifndef SC_FX_EXCLUDE_OTHER
221 #define DECL_BIN_FNC_OTHER(fnc) \
222 DECL_BIN_FNC_T(fnc,int64) \
223 DECL_BIN_FNC_T(fnc,uint64) \
224 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
225 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
226 DECL_BIN_FNC_T(fnc,const sc_signed&) \
227 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
229 #define DECL_BIN_FNC_OTHER(fnc)
232 #define DECL_BIN_FNC(fnc) \
233 friend void fnc ( sc_fxval&, const sc_fxval&, const sc_fxval& ); \
234 DECL_BIN_FNC_T(fnc,int) \
235 DECL_BIN_FNC_T(fnc,unsigned int) \
236 DECL_BIN_FNC_T(fnc,long) \
237 DECL_BIN_FNC_T(fnc,unsigned long) \
238 DECL_BIN_FNC_T(fnc,float) \
239 DECL_BIN_FNC_T(fnc,double) \
240 DECL_BIN_FNC_T(fnc,const char*) \
241 DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \
242 DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&) \
243 DECL_BIN_FNC_OTHER(fnc)
250 #undef DECL_BIN_FNC_T
251 #undef DECL_BIN_FNC_OTHER
254 friend void lshift( sc_fxval&,
const sc_fxval&,
int );
255 friend void rshift( sc_fxval&,
const sc_fxval&,
int );
260 #define DECL_REL_OP_T(op,tp) \
261 friend bool operator op ( const sc_fxval&, tp ); \
262 friend bool operator op ( tp, const sc_fxval& );
264 #ifndef SC_FX_EXCLUDE_OTHER
265 #define DECL_REL_OP_OTHER(op) \
266 DECL_REL_OP_T(op,int64) \
267 DECL_REL_OP_T(op,uint64) \
268 DECL_REL_OP_T(op,const sc_int_base&) \
269 DECL_REL_OP_T(op,const sc_uint_base&) \
270 DECL_REL_OP_T(op,const sc_signed&) \
271 DECL_REL_OP_T(op,const sc_unsigned&)
273 #define DECL_REL_OP_OTHER(op)
276 #define DECL_REL_OP(op) \
277 friend bool operator op ( const sc_fxval&, const sc_fxval& ); \
278 DECL_REL_OP_T(op,int) \
279 DECL_REL_OP_T(op,unsigned int) \
280 DECL_REL_OP_T(op,long) \
281 DECL_REL_OP_T(op,unsigned long) \
282 DECL_REL_OP_T(op,float) \
283 DECL_REL_OP_T(op,double) \
284 DECL_REL_OP_T(op,const char*) \
285 DECL_REL_OP_T(op,const sc_fxval_fast&) \
286 DECL_REL_OP_T(op,const sc_fxnum_fast&) \
287 DECL_REL_OP_OTHER(op)
297 #undef DECL_REL_OP_OTHER
303 #define DECL_ASN_OP_T(op,tp) \
304 sc_fxval& operator op( tp );
306 #ifndef SC_FX_EXCLUDE_OTHER
307 #define DECL_ASN_OP_OTHER(op) \
308 DECL_ASN_OP_T(op,int64) \
309 DECL_ASN_OP_T(op,uint64) \
310 DECL_ASN_OP_T(op,const sc_int_base&) \
311 DECL_ASN_OP_T(op,const sc_uint_base&) \
312 DECL_ASN_OP_T(op,const sc_signed&) \
313 DECL_ASN_OP_T(op,const sc_unsigned&)
315 #define DECL_ASN_OP_OTHER(op)
318 #define DECL_ASN_OP(op) \
319 DECL_ASN_OP_T(op,int) \
320 DECL_ASN_OP_T(op,unsigned int) \
321 DECL_ASN_OP_T(op,long) \
322 DECL_ASN_OP_T(op,unsigned long) \
323 DECL_ASN_OP_T(op,float) \
324 DECL_ASN_OP_T(op,double) \
325 DECL_ASN_OP_T(op,const char*) \
326 DECL_ASN_OP_T(op,const sc_fxval&) \
327 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
328 DECL_ASN_OP_T(op,const sc_fxnum&) \
329 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
330 DECL_ASN_OP_OTHER(op)
340 DECL_ASN_OP_T(>>=,
int)
343 #undef DECL_ASN_OP_OTHER
358 operator double()
const;
384 const std::string
to_dec()
const;
385 const std::string
to_bin()
const;
386 const std::string
to_oct()
const;
387 const std::string
to_hex()
const;
403 void print( ::std::ostream& = ::std::cout )
const;
404 void scan( ::std::istream& = ::std::cin );
405 void dump( ::std::ostream& = ::std::cout )
const;
460 #ifndef SC_FX_EXCLUDE_OTHER
489 #define DECL_BIN_OP_T(op,tp) \
490 friend const sc_fxval_fast operator op ( const sc_fxval_fast&, tp ); \
491 friend const sc_fxval_fast operator op ( tp, const sc_fxval_fast& );
493 #ifndef SC_FX_EXCLUDE_OTHER
494 #define DECL_BIN_OP_OTHER(op) \
495 DECL_BIN_OP_T(op,int64) \
496 DECL_BIN_OP_T(op,uint64) \
497 DECL_BIN_OP_T(op,const sc_int_base&) \
498 DECL_BIN_OP_T(op,const sc_uint_base&) \
499 DECL_BIN_OP_T(op,const sc_signed&) \
500 DECL_BIN_OP_T(op,const sc_unsigned&)
502 #define DECL_BIN_OP_OTHER(op)
505 #define DECL_BIN_OP(op,dummy) \
506 friend const sc_fxval_fast operator op ( const sc_fxval_fast&, \
507 const sc_fxval_fast& ); \
508 DECL_BIN_OP_T(op,int) \
509 DECL_BIN_OP_T(op,unsigned int) \
510 DECL_BIN_OP_T(op,long) \
511 DECL_BIN_OP_T(op,unsigned long) \
512 DECL_BIN_OP_T(op,float) \
513 DECL_BIN_OP_T(op,double) \
514 DECL_BIN_OP_T(op,const char*) \
515 DECL_BIN_OP_OTHER(op)
523 const sc_fxval_fast& );
525 DECL_BIN_OP_T(/,
unsigned int)
526 DECL_BIN_OP_T(/,
long)
527 DECL_BIN_OP_T(/,
unsigned long)
528 DECL_BIN_OP_T(/,
float)
529 DECL_BIN_OP_T(/,
double)
530 DECL_BIN_OP_T(/,const
char*)
532 #ifndef SC_FX_EXCLUDE_OTHER
542 #undef DECL_BIN_OP_OTHER
545 friend const sc_fxval_fast
operator << (
const sc_fxval_fast&,
int );
546 friend const sc_fxval_fast
operator >> (
const sc_fxval_fast&,
int );
551 #define DECL_BIN_FNC_T(fnc,tp) \
552 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, tp ); \
553 friend void fnc ( sc_fxval_fast&, tp, const sc_fxval_fast& );
555 #ifndef SC_FX_EXCLUDE_OTHER
556 #define DECL_BIN_FNC_OTHER(fnc) \
557 DECL_BIN_FNC_T(fnc,int64) \
558 DECL_BIN_FNC_T(fnc,uint64) \
559 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
560 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
561 DECL_BIN_FNC_T(fnc,const sc_signed&) \
562 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
564 #define DECL_BIN_FNC_OTHER(fnc)
567 #define DECL_BIN_FNC(fnc) \
568 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, \
569 const sc_fxval_fast& ); \
570 DECL_BIN_FNC_T(fnc,int) \
571 DECL_BIN_FNC_T(fnc,unsigned int) \
572 DECL_BIN_FNC_T(fnc,long) \
573 DECL_BIN_FNC_T(fnc,unsigned long) \
574 DECL_BIN_FNC_T(fnc,float) \
575 DECL_BIN_FNC_T(fnc,double) \
576 DECL_BIN_FNC_T(fnc,const char*) \
577 DECL_BIN_FNC_T(fnc,const sc_fxval&) \
578 DECL_BIN_FNC_T(fnc,const sc_fxnum&) \
579 DECL_BIN_FNC_OTHER(fnc)
586 #undef DECL_BIN_FNC_T
587 #undef DECL_BIN_FNC_OTHER
590 friend void lshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
591 friend void rshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
596 #define DECL_REL_OP_T(op,tp) \
597 friend bool operator op ( const sc_fxval_fast&, tp ); \
598 friend bool operator op ( tp, const sc_fxval_fast& );
600 #ifndef SC_FX_EXCLUDE_OTHER
601 #define DECL_REL_OP_OTHER(op) \
602 DECL_REL_OP_T(op,int64) \
603 DECL_REL_OP_T(op,uint64) \
604 DECL_REL_OP_T(op,const sc_int_base&) \
605 DECL_REL_OP_T(op,const sc_uint_base&) \
606 DECL_REL_OP_T(op,const sc_signed&) \
607 DECL_REL_OP_T(op,const sc_unsigned&)
609 #define DECL_REL_OP_OTHER(op)
612 #define DECL_REL_OP(op) \
613 friend bool operator op ( const sc_fxval_fast&, const sc_fxval_fast& ); \
614 DECL_REL_OP_T(op,int) \
615 DECL_REL_OP_T(op,unsigned int) \
616 DECL_REL_OP_T(op,long) \
617 DECL_REL_OP_T(op,unsigned long) \
618 DECL_REL_OP_T(op,float) \
619 DECL_REL_OP_T(op,double) \
620 DECL_REL_OP_T(op,const char*) \
621 DECL_REL_OP_OTHER(op)
631 #undef DECL_REL_OP_OTHER
637 #define DECL_ASN_OP_T(op,tp) \
638 sc_fxval_fast& operator op( tp );
640 #ifndef SC_FX_EXCLUDE_OTHER
641 #define DECL_ASN_OP_OTHER(op) \
642 DECL_ASN_OP_T(op,int64) \
643 DECL_ASN_OP_T(op,uint64) \
644 DECL_ASN_OP_T(op,const sc_int_base&) \
645 DECL_ASN_OP_T(op,const sc_uint_base&) \
646 DECL_ASN_OP_T(op,const sc_signed&) \
647 DECL_ASN_OP_T(op,const sc_unsigned&)
649 #define DECL_ASN_OP_OTHER(op)
652 #define DECL_ASN_OP(op) \
653 DECL_ASN_OP_T(op,int) \
654 DECL_ASN_OP_T(op,unsigned int) \
655 DECL_ASN_OP_T(op,long) \
656 DECL_ASN_OP_T(op,unsigned long) \
657 DECL_ASN_OP_T(op,float) \
658 DECL_ASN_OP_T(op,double) \
659 DECL_ASN_OP_T(op,const char*) \
660 DECL_ASN_OP_T(op,const sc_fxval&) \
661 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
662 DECL_ASN_OP_T(op,const sc_fxnum&) \
663 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
664 DECL_ASN_OP_OTHER(op)
674 DECL_ASN_OP_T(>>=,
int)
677 #undef DECL_ASN_OP_OTHER
692 operator double()
const;
718 const std::string
to_dec()
const;
719 const std::string
to_bin()
const;
720 const std::string
to_oct()
const;
721 const std::string
to_hex()
const;
737 void print( ::std::ostream& = ::std::cout )
const;
738 void scan( ::std::istream& = ::std::cin );
739 void dump( ::std::ostream& = ::std::cout )
const;
757 mutable sc_fxval_fast_observer* m_observer;
783 : m_rep( a != 0 ? a : new
scfx_rep ),
793 m_observer( observer_ )
802 : m_rep( new
scfx_rep( *a.m_rep ) ),
803 m_observer( observer_ )
811 #define DEFN_CTOR_T(tp,arg) \
813 sc_fxval::sc_fxval( tp a, \
814 sc_fxval_observer* observer_ ) \
815 : m_rep( new scfx_rep( arg ) ), \
816 m_observer( observer_ ) \
818 SC_FXVAL_OBSERVER_DEFAULT_ \
819 SC_FXVAL_OBSERVER_CONSTRUCT_( *this ) \
820 SC_FXVAL_OBSERVER_WRITE_( *this ) \
823 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a)
824 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,a.to_double())
825 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.value())
835 #ifndef SC_FX_EXCLUDE_OTHER
901 neg( sc_fxval& c,
const sc_fxval& a )
912 #define DEFN_BIN_OP_T(op,fnc,tp) \
915 operator op ( const sc_fxval& a, tp b ) \
917 SC_FXVAL_OBSERVER_READ_( a ) \
919 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) ); \
924 operator op ( tp a, const sc_fxval& b ) \
926 SC_FXVAL_OBSERVER_READ_( b ) \
928 return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) ); \
931 #ifndef SC_FX_EXCLUDE_OTHER
932 #define DEFN_BIN_OP_OTHER(op,fnc) \
933 DEFN_BIN_OP_T(op,fnc,int64) \
934 DEFN_BIN_OP_T(op,fnc,uint64) \
935 DEFN_BIN_OP_T(op,fnc,const sc_int_base&) \
936 DEFN_BIN_OP_T(op,fnc,const sc_uint_base&) \
937 DEFN_BIN_OP_T(op,fnc,const sc_signed&) \
938 DEFN_BIN_OP_T(op,fnc,const sc_unsigned&)
940 #define DEFN_BIN_OP_OTHER(op,fnc)
943 #define DEFN_BIN_OP(op,fnc) \
946 operator op ( const sc_fxval& a, const sc_fxval& b ) \
948 SC_FXVAL_OBSERVER_READ_( a ) \
949 SC_FXVAL_OBSERVER_READ_( b ) \
950 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \
953 DEFN_BIN_OP_T(op,fnc,int) \
954 DEFN_BIN_OP_T(op,fnc,unsigned int) \
955 DEFN_BIN_OP_T(op,fnc,long) \
956 DEFN_BIN_OP_T(op,fnc,unsigned long) \
957 DEFN_BIN_OP_T(op,fnc,float) \
958 DEFN_BIN_OP_T(op,fnc,double) \
959 DEFN_BIN_OP_T(op,fnc,const char*) \
960 DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&) \
961 DEFN_BIN_OP_OTHER(op,fnc)
970 operator / ( const sc_fxval& a, const sc_fxval&
b )
979 DEFN_BIN_OP_T(/,div,
long)
980 DEFN_BIN_OP_T(/,div,
unsigned long)
981 DEFN_BIN_OP_T(/,div,
float)
982 DEFN_BIN_OP_T(/,div,
double)
983 DEFN_BIN_OP_T(/,div,const
char*)
984 DEFN_BIN_OP_T(/,div,const sc_fxval_fast&)
986 #ifndef SC_FX_EXCLUDE_OTHER
996 #undef DEFN_BIN_OP_OTHER
1019 #define DEFN_BIN_FNC_T(fnc,tp) \
1022 fnc ( sc_fxval& c, const sc_fxval& a, tp b ) \
1024 SC_FXVAL_OBSERVER_READ_( a ) \
1025 sc_fxval tmp( b ); \
1027 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ); \
1028 SC_FXVAL_OBSERVER_WRITE_( c ) \
1033 fnc ( sc_fxval& c, tp a, const sc_fxval& b ) \
1035 SC_FXVAL_OBSERVER_READ_( b ) \
1036 sc_fxval tmp( a ); \
1038 c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ); \
1039 SC_FXVAL_OBSERVER_WRITE_( c ) \
1042 #ifndef SC_FX_EXCLUDE_OTHER
1043 #define DEFN_BIN_FNC_OTHER(fnc) \
1044 DEFN_BIN_FNC_T(fnc,int64) \
1045 DEFN_BIN_FNC_T(fnc,uint64) \
1046 DEFN_BIN_FNC_T(fnc,const sc_int_base&) \
1047 DEFN_BIN_FNC_T(fnc,const sc_uint_base&) \
1048 DEFN_BIN_FNC_T(fnc,const sc_signed&) \
1049 DEFN_BIN_FNC_T(fnc,const sc_unsigned&)
1051 #define DEFN_BIN_FNC_OTHER(fnc)
1054 #define DEFN_BIN_FNC(fnc) \
1057 fnc( sc_fxval& c, const sc_fxval& a, const sc_fxval& b ) \
1059 SC_FXVAL_OBSERVER_READ_( a ) \
1060 SC_FXVAL_OBSERVER_READ_( b ) \
1062 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ); \
1063 SC_FXVAL_OBSERVER_WRITE_( c ) \
1066 DEFN_BIN_FNC_T(fnc,int) \
1067 DEFN_BIN_FNC_T(fnc,unsigned int) \
1068 DEFN_BIN_FNC_T(fnc,long) \
1069 DEFN_BIN_FNC_T(fnc,unsigned long) \
1070 DEFN_BIN_FNC_T(fnc,float) \
1071 DEFN_BIN_FNC_T(fnc,double) \
1072 DEFN_BIN_FNC_T(fnc,const char*) \
1073 DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&) \
1074 DEFN_BIN_FNC_OTHER(fnc)
1081 #undef DEFN_BIN_FNC_T
1082 #undef DEFN_BIN_FNC_OTHER
1109 #define DEFN_REL_OP_T(op,ret,tp) \
1112 operator op ( const sc_fxval& a, tp b ) \
1114 SC_FXVAL_OBSERVER_READ_( a ) \
1115 sc_fxval tmp( b ); \
1116 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep ); \
1122 operator op ( tp a, const sc_fxval& b ) \
1124 SC_FXVAL_OBSERVER_READ_( b ) \
1125 sc_fxval tmp( a ); \
1126 int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep ); \
1130 #ifndef SC_FX_EXCLUDE_OTHER
1131 #define DEFN_REL_OP_OTHER(op,ret) \
1132 DEFN_REL_OP_T(op,ret,int64) \
1133 DEFN_REL_OP_T(op,ret,uint64) \
1134 DEFN_REL_OP_T(op,ret,const sc_int_base&) \
1135 DEFN_REL_OP_T(op,ret,const sc_uint_base&) \
1136 DEFN_REL_OP_T(op,ret,const sc_signed&) \
1137 DEFN_REL_OP_T(op,ret,const sc_unsigned&)
1139 #define DEFN_REL_OP_OTHER(op,ret)
1142 #define DEFN_REL_OP(op,ret) \
1145 operator op ( const sc_fxval& a, const sc_fxval& b) \
1147 SC_FXVAL_OBSERVER_READ_( a ) \
1148 SC_FXVAL_OBSERVER_READ_( b ) \
1149 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep ); \
1153 DEFN_REL_OP_T(op,ret,int) \
1154 DEFN_REL_OP_T(op,ret,unsigned int) \
1155 DEFN_REL_OP_T(op,ret,long) \
1156 DEFN_REL_OP_T(op,ret,unsigned long) \
1157 DEFN_REL_OP_T(op,ret,float) \
1158 DEFN_REL_OP_T(op,ret,double) \
1159 DEFN_REL_OP_T(op,ret,const char*) \
1160 DEFN_REL_OP_T(op,ret,const sc_fxval_fast&) \
1161 DEFN_REL_OP_OTHER(op,ret)
1166 DEFN_REL_OP(>=,result >= 0 && result != 2)
1167 DEFN_REL_OP(==,result == 0)
1168 DEFN_REL_OP(!=,result != 0)
1170 #undef DEFN_REL_OP_T
1171 #undef DEFN_REL_OP_OTHER
1179 sc_fxval::operator = (
const sc_fxval& a )
1190 #define DEFN_ASN_OP_T(tp) \
1193 sc_fxval::operator = ( tp b ) \
1195 sc_fxval tmp( b ); \
1196 *m_rep = *tmp.m_rep; \
1197 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1209 #ifndef SC_FX_EXCLUDE_OTHER
1218 #undef DEFN_ASN_OP_T
1221 #define DEFN_ASN_OP_T(op,fnc,tp) \
1224 sc_fxval::operator op ( tp b ) \
1226 SC_FXVAL_OBSERVER_READ_( *this ) \
1227 sc_fxval tmp( b ); \
1228 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep ); \
1231 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1235 #ifndef SC_FX_EXCLUDE_OTHER
1236 #define DEFN_ASN_OP_OTHER(op,fnc) \
1237 DEFN_ASN_OP_T(op,fnc,int64) \
1238 DEFN_ASN_OP_T(op,fnc,uint64) \
1239 DEFN_ASN_OP_T(op,fnc,const sc_int_base&) \
1240 DEFN_ASN_OP_T(op,fnc,const sc_uint_base&) \
1241 DEFN_ASN_OP_T(op,fnc,const sc_signed&) \
1242 DEFN_ASN_OP_T(op,fnc,const sc_unsigned&)
1244 #define DEFN_ASN_OP_OTHER(op,fnc)
1247 #define DEFN_ASN_OP(op,fnc) \
1250 sc_fxval::operator op ( const sc_fxval& b ) \
1252 SC_FXVAL_OBSERVER_READ_( *this ) \
1253 SC_FXVAL_OBSERVER_READ_( b ) \
1254 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep ); \
1257 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1261 DEFN_ASN_OP_T(op,fnc,int) \
1262 DEFN_ASN_OP_T(op,fnc,unsigned int) \
1263 DEFN_ASN_OP_T(op,fnc,long) \
1264 DEFN_ASN_OP_T(op,fnc,unsigned long) \
1265 DEFN_ASN_OP_T(op,fnc,float) \
1266 DEFN_ASN_OP_T(op,fnc,double) \
1267 DEFN_ASN_OP_T(op,fnc,const char*) \
1268 DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&) \
1269 DEFN_ASN_OP_OTHER(op,fnc)
1276 #undef DEFN_ASN_OP_T
1277 #undef DEFN_ASN_OP_OTHER
1283 sc_fxval::operator <<= (
int b )
1293 sc_fxval::operator >>= (
int b )
1306 sc_fxval::operator ++ (
int )
1342 sc_fxval::operator double()
const
1356 return static_cast<short>( m_rep->
to_double() );
1364 return static_cast<unsigned short>( m_rep->
to_double() );
1372 return static_cast<int>( m_rep->
to_double() );
1396 return static_cast<long>( m_rep->
to_double() );
1404 return static_cast<unsigned int>( m_rep->
to_double() );
1412 return static_cast<unsigned long>( m_rep->
to_double() );
1420 return static_cast<float>( m_rep->
to_double() );
1543 sc_fxval_fast_observer*
1555 m_observer( observer_ )
1565 m_observer( observer_ )
1573 #define DEFN_CTOR_T(tp,arg) \
1575 sc_fxval_fast::sc_fxval_fast( tp a, \
1576 sc_fxval_fast_observer* observer_ ) \
1578 m_observer( observer_ ) \
1580 SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
1581 SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this ) \
1582 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1585 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a ))
1586 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,from_string( a ))
1587 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
1597 #ifndef SC_FX_EXCLUDE_OTHER
1607 #undef DEFN_CTOR_T_A
1608 #undef DEFN_CTOR_T_B
1609 #undef DEFN_CTOR_T_C
1610 #undef DEFN_CTOR_T_D
1611 #undef DEFN_CTOR_T_E
1651 const sc_fxval_fast&
1663 neg( sc_fxval_fast& c,
const sc_fxval_fast& a )
1666 c.m_val = - a.m_val;
1673 #define DEFN_BIN_OP_T(op,tp) \
1675 const sc_fxval_fast \
1676 operator op ( const sc_fxval_fast& a, tp b ) \
1678 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1679 sc_fxval_fast tmp( b ); \
1680 return sc_fxval_fast( a.m_val op tmp.m_val ); \
1684 const sc_fxval_fast \
1685 operator op ( tp a, const sc_fxval_fast& b ) \
1687 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1688 sc_fxval_fast tmp( a ); \
1689 return sc_fxval_fast( tmp.m_val op b.m_val ); \
1692 #ifndef SC_FX_EXCLUDE_OTHER
1693 #define DEFN_BIN_OP_OTHER(op) \
1694 DEFN_BIN_OP_T(op,int64) \
1695 DEFN_BIN_OP_T(op,uint64) \
1696 DEFN_BIN_OP_T(op,const sc_int_base&) \
1697 DEFN_BIN_OP_T(op,const sc_uint_base&) \
1698 DEFN_BIN_OP_T(op,const sc_signed&) \
1699 DEFN_BIN_OP_T(op,const sc_unsigned&)
1701 #define DEFN_BIN_OP_OTHER(op)
1704 #define DEFN_BIN_OP(op,dummy) \
1706 const sc_fxval_fast \
1707 operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1709 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1710 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1711 return sc_fxval_fast( a.m_val op b.m_val ); \
1714 DEFN_BIN_OP_T(op,int) \
1715 DEFN_BIN_OP_T(op,unsigned int) \
1716 DEFN_BIN_OP_T(op,long) \
1717 DEFN_BIN_OP_T(op,unsigned long) \
1718 DEFN_BIN_OP_T(op,float) \
1719 DEFN_BIN_OP_T(op,double) \
1720 DEFN_BIN_OP_T(op,const char*) \
1721 DEFN_BIN_OP_OTHER(op)
1729 operator / ( const sc_fxval_fast& a, const sc_fxval_fast& b )
1733 return sc_fxval_fast( a.m_val / b.m_val );
1737 DEFN_BIN_OP_T(/,
unsigned int)
1738 DEFN_BIN_OP_T(/,
long)
1739 DEFN_BIN_OP_T(/,
unsigned long)
1740 DEFN_BIN_OP_T(/,
float)
1741 DEFN_BIN_OP_T(/,
double)
1742 DEFN_BIN_OP_T(/,const
char*)
1744 #ifndef SC_FX_EXCLUDE_OTHER
1747 DEFN_BIN_OP_T(/,const sc_int_base&)
1748 DEFN_BIN_OP_T(/,const sc_uint_base&)
1749 DEFN_BIN_OP_T(/,const sc_signed&)
1750 DEFN_BIN_OP_T(/,const sc_unsigned&)
1754 #undef DEFN_BIN_OP_T
1755 #undef DEFN_BIN_OP_OTHER
1764 return sc_fxval_fast( a.m_val *
scfx_pow2( b ) );
1772 return sc_fxval_fast( a.m_val *
scfx_pow2( -b ) );
1778 #define DEFN_BIN_FNC_T(fnc,op,tp) \
1781 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b ) \
1783 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1784 sc_fxval_fast tmp( b ); \
1785 c.m_val = a.m_val op tmp.m_val; \
1786 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1791 fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b ) \
1793 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1794 sc_fxval_fast tmp( a ); \
1795 c.m_val = tmp.m_val op b.m_val; \
1796 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1799 #ifndef SC_FX_EXCLUDE_OTHER
1800 #define DEFN_BIN_FNC_OTHER(fnc,op) \
1801 DEFN_BIN_FNC_T(fnc,op,int64) \
1802 DEFN_BIN_FNC_T(fnc,op,uint64) \
1803 DEFN_BIN_FNC_T(fnc,op,const sc_int_base&) \
1804 DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&) \
1805 DEFN_BIN_FNC_T(fnc,op,const sc_signed&) \
1806 DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&)
1808 #define DEFN_BIN_FNC_OTHER(fnc,op)
1811 #define DEFN_BIN_FNC(fnc,op) \
1814 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1816 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1817 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1818 c.m_val = a.m_val op b.m_val; \
1819 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1822 DEFN_BIN_FNC_T(fnc,op,int) \
1823 DEFN_BIN_FNC_T(fnc,op,unsigned int) \
1824 DEFN_BIN_FNC_T(fnc,op,long) \
1825 DEFN_BIN_FNC_T(fnc,op,unsigned long) \
1826 DEFN_BIN_FNC_T(fnc,op,float) \
1827 DEFN_BIN_FNC_T(fnc,op,double) \
1828 DEFN_BIN_FNC_T(fnc,op,const char*) \
1829 DEFN_BIN_FNC_OTHER(fnc,op)
1836 #undef DEFN_BIN_FNC_T
1837 #undef DEFN_BIN_FNC_OTHER
1843 lshift( sc_fxval_fast& c,
const sc_fxval_fast& a,
int b )
1852 rshift( sc_fxval_fast& c,
const sc_fxval_fast& a,
int b )
1862 #define DEFN_REL_OP_T(op,tp) \
1865 operator op ( const sc_fxval_fast& a, tp b ) \
1867 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1868 sc_fxval_fast tmp( b ); \
1869 return ( a.m_val op tmp.m_val ); \
1874 operator op ( tp a, const sc_fxval_fast& b ) \
1876 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1877 sc_fxval_fast tmp( a ); \
1878 return ( tmp.m_val op b.m_val ); \
1881 #ifndef SC_FX_EXCLUDE_OTHER
1882 #define DEFN_REL_OP_OTHER(op) \
1883 DEFN_REL_OP_T(op,int64) \
1884 DEFN_REL_OP_T(op,uint64) \
1885 DEFN_REL_OP_T(op,const sc_int_base&) \
1886 DEFN_REL_OP_T(op,const sc_uint_base&) \
1887 DEFN_REL_OP_T(op,const sc_signed&) \
1888 DEFN_REL_OP_T(op,const sc_unsigned&)
1890 #define DEFN_REL_OP_OTHER(op)
1893 #define DEFN_REL_OP(op) \
1896 operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1898 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1899 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1900 return ( a.m_val op b.m_val ); \
1903 DEFN_REL_OP_T(op,int) \
1904 DEFN_REL_OP_T(op,unsigned int) \
1905 DEFN_REL_OP_T(op,long) \
1906 DEFN_REL_OP_T(op,unsigned long) \
1907 DEFN_REL_OP_T(op,float) \
1908 DEFN_REL_OP_T(op,double) \
1909 DEFN_REL_OP_T(op,const char*) \
1910 DEFN_REL_OP_OTHER(op)
1919 #undef DEFN_REL_OP_T
1920 #undef DEFN_REL_OP_OTHER
1928 sc_fxval_fast::operator = (
const sc_fxval_fast& a )
1939 #define DEFN_ASN_OP_T(tp) \
1942 sc_fxval_fast::operator = ( tp a ) \
1944 sc_fxval_fast tmp( a ); \
1945 m_val = tmp.m_val; \
1946 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1958 #ifndef SC_FX_EXCLUDE_OTHER
1967 #undef DEFN_ASN_OP_T
1970 #define DEFN_ASN_OP_T(op,tp) \
1973 sc_fxval_fast::operator op ( tp b ) \
1975 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
1976 sc_fxval_fast tmp( b ); \
1977 m_val op tmp.m_val; \
1978 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1982 #ifndef SC_FX_EXCLUDE_OTHER
1983 #define DEFN_ASN_OP_OTHER(op) \
1984 DEFN_ASN_OP_T(op,int64) \
1985 DEFN_ASN_OP_T(op,uint64) \
1986 DEFN_ASN_OP_T(op,const sc_int_base&) \
1987 DEFN_ASN_OP_T(op,const sc_uint_base&) \
1988 DEFN_ASN_OP_T(op,const sc_signed&) \
1989 DEFN_ASN_OP_T(op,const sc_unsigned&)
1991 #define DEFN_ASN_OP_OTHER(op)
1994 #define DEFN_ASN_OP(op) \
1997 sc_fxval_fast::operator op ( const sc_fxval_fast& b ) \
1999 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
2000 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
2002 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
2006 DEFN_ASN_OP_T(op,int) \
2007 DEFN_ASN_OP_T(op,unsigned int) \
2008 DEFN_ASN_OP_T(op,long) \
2009 DEFN_ASN_OP_T(op,unsigned long) \
2010 DEFN_ASN_OP_T(op,float) \
2011 DEFN_ASN_OP_T(op,double) \
2012 DEFN_ASN_OP_T(op,const char*) \
2013 DEFN_ASN_OP_T(op,const sc_fxval&) \
2014 DEFN_ASN_OP_OTHER(op)
2021 #undef DEFN_ASN_OP_T
2022 #undef DEFN_ASN_OP_OTHER
2028 sc_fxval_fast::operator <<= (
int b )
2038 sc_fxval_fast::operator >>= (
int b )
2051 sc_fxval_fast::operator ++ (
int )
2097 sc_fxval_fast::operator double()
const
2111 return static_cast<short>( m_val );
2119 return static_cast<unsigned short>( m_val );
2127 return static_cast<int64>( m_val );
2135 return static_cast<int>( m_val );
2143 return static_cast<unsigned int>( m_val );
2151 return static_cast<uint64>( m_val );
2159 return static_cast<long>( m_val );
2167 return static_cast<unsigned long>( m_val );
2175 return static_cast<float>( m_val );
2195 return (
id.negative() != 0 );
2204 return id.is_zero();
2262 #undef SCFX_EXPLICIT_
2263 #undef SCFX_EXPLICIT_OTHER_
#define DEFN_ASN_OP_T(op, tp)
const std::string to_string() const
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
friend const sc_fxval_fast operator>>(const sc_fxval_fast &, int)
void scan(::std::istream &=::std::cin)
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int)
const std::string to_hex() const
void unlock_observer(sc_fxval_observer *) const
void get_type(int &, int &, sc_enc &) const
#define SCFX_EXPLICIT_OTHER_
friend const sc_fxval operator>>(const sc_fxval &, int)
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
const scfx_rep * get_rep() const
bool rounding_flag() const
unsigned long to_ulong() const
void scan(::std::istream &=::std::cin)
void get_type(int &, int &, sc_enc &) const
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
friend void neg(sc_fxval &, const sc_fxval &)
sc_fxval_observer * observer() const
const sc_fxval operator-() const
void dump(::std::ostream &=::std::cout) const
#define SC_FXVAL_OBSERVER_DEFAULT_
sc_fxval_observer * lock_observer() const
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
#define DECL_BIN_FNC(fnc)
const std::string to_string() const
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/
scfx_rep * neg_scfx_rep(const scfx_rep &)
uint64 const sc_uint_base int b
#define DECL_ASN_OP_T(op, tp)
sc_fxval_fast_observer * observer() const
friend void lshift(sc_fxval &, const sc_fxval &, int)
unsigned int to_uint() const
sc_fxval_fast_observer * lock_observer() const
const std::string to_oct() const
#define DEFN_BIN_OP(ret, op)
unsigned int to_uint() const
unsigned short to_ushort() const
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
friend void neg(sc_fxval_fast &, const sc_fxval_fast &)
inline::std::istream & operator>>(::std::istream &is, sc_bit &a)
const sc_fxval overflow(const scfx_params &, bool &) const
#define SC_FXVAL_OBSERVER_READ_(object)
void print(::std::ostream &=::std::cout) const
void unlock_observer(sc_fxval_fast_observer *) const
void dump(::std::ostream &=::std::cout) const
bool rounding_flag() const
const std::string to_oct() const
scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
#define DEFN_CTOR_T_A(tp)
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
#define DEFN_BIN_FNC(fnc)
unsigned long to_ulong() const
friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int)
unsigned short to_ushort() const
const std::string to_hex() const
void print(::std::ostream &=::std::cout) const
friend void rshift(sc_fxval &, const sc_fxval &, int)
const sc_fxval & operator+() const
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
const std::string to_bin() const
const std::string to_dec() const
double scfx_pow2(int exp)
#define DEFN_CTOR_T_B(tp)
void neg(sc_fxval &c, const sc_fxnum &a)
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
const std::string to_bin() const
const sc_fxval_fast & operator+() const
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
#define DECL_BIN_OP(op, dummy)
const sc_fxval_fast operator-() const
#define DEFN_CTOR_T_C(tp)
sc_fxval_fast(sc_fxval_fast_observer *=0)
sc_fxval_fast & operator++()
bool rounding_flag() const
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
const std::string to_dec() const
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
DEFN_BIN_OP_T(/, div, int64) DEFN_BIN_OP_T(/
static double from_string(const char *)
sc_fxval_fast & operator--()
const sc_fxval quantization(const scfx_params &, bool &) const
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/