58 #ifndef SC_FX_EXCLUDE_OTHER 66 #ifdef SC_FXVAL_IMPLICIT_CONV 67 # define SCFX_EXPLICIT_ // nothing 69 # define SCFX_EXPLICIT_ explicit 71 #ifdef SC_FXVAL_IMPLICIT_OTHER 72 # define SCFX_EXPLICIT_OTHER_ 74 # define SCFX_EXPLICIT_OTHER_ explicit 122 #ifndef SC_FX_EXCLUDE_OTHER 152 #define DECL_BIN_OP_T(op,tp) \ 153 friend const sc_fxval operator op ( const sc_fxval&, tp ); \ 154 friend const sc_fxval operator op ( tp, const sc_fxval& ); 156 #ifndef SC_FX_EXCLUDE_OTHER 157 #define DECL_BIN_OP_OTHER(op) \ 158 DECL_BIN_OP_T(op,int64) \ 159 DECL_BIN_OP_T(op,uint64) \ 160 DECL_BIN_OP_T(op,const sc_int_base&) \ 161 DECL_BIN_OP_T(op,const sc_uint_base&) \ 162 DECL_BIN_OP_T(op,const sc_signed&) \ 163 DECL_BIN_OP_T(op,const sc_unsigned&) 165 #define DECL_BIN_OP_OTHER(op) 168 #define DECL_BIN_OP(op,dummy) \ 169 friend const sc_fxval operator op ( const sc_fxval&, const sc_fxval& ); \ 170 DECL_BIN_OP_T(op,int) \ 171 DECL_BIN_OP_T(op,unsigned int) \ 172 DECL_BIN_OP_T(op,long) \ 173 DECL_BIN_OP_T(op,unsigned long) \ 174 DECL_BIN_OP_T(op,float) \ 175 DECL_BIN_OP_T(op,double) \ 176 DECL_BIN_OP_T(op,const char*) \ 177 DECL_BIN_OP_T(op,const sc_fxval_fast&) \ 178 DECL_BIN_OP_T(op,const sc_fxnum_fast&) \ 179 DECL_BIN_OP_OTHER(op) 198 #ifndef SC_FX_EXCLUDE_OTHER 209 #undef DECL_BIN_OP_OTHER 218 #define DECL_BIN_FNC_T(fnc,tp) \ 219 friend void fnc ( sc_fxval&, const sc_fxval&, tp ); \ 220 friend void fnc ( sc_fxval&, tp, const sc_fxval& ); 222 #ifndef SC_FX_EXCLUDE_OTHER 223 #define DECL_BIN_FNC_OTHER(fnc) \ 224 DECL_BIN_FNC_T(fnc,int64) \ 225 DECL_BIN_FNC_T(fnc,uint64) \ 226 DECL_BIN_FNC_T(fnc,const sc_int_base&) \ 227 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \ 228 DECL_BIN_FNC_T(fnc,const sc_signed&) \ 229 DECL_BIN_FNC_T(fnc,const sc_unsigned&) 231 #define DECL_BIN_FNC_OTHER(fnc) 234 #define DECL_BIN_FNC(fnc) \ 235 friend void fnc ( sc_fxval&, const sc_fxval&, const sc_fxval& ); \ 236 DECL_BIN_FNC_T(fnc,int) \ 237 DECL_BIN_FNC_T(fnc,unsigned int) \ 238 DECL_BIN_FNC_T(fnc,long) \ 239 DECL_BIN_FNC_T(fnc,unsigned long) \ 240 DECL_BIN_FNC_T(fnc,float) \ 241 DECL_BIN_FNC_T(fnc,double) \ 242 DECL_BIN_FNC_T(fnc,const char*) \ 243 DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \ 244 DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&) \ 245 DECL_BIN_FNC_OTHER(fnc) 252 #undef DECL_BIN_FNC_T 253 #undef DECL_BIN_FNC_OTHER 262 #define DECL_REL_OP_T(op,tp) \ 263 friend bool operator op ( const sc_fxval&, tp ); \ 264 friend bool operator op ( tp, const sc_fxval& ); 266 #ifndef SC_FX_EXCLUDE_OTHER 267 #define DECL_REL_OP_OTHER(op) \ 268 DECL_REL_OP_T(op,int64) \ 269 DECL_REL_OP_T(op,uint64) \ 270 DECL_REL_OP_T(op,const sc_int_base&) \ 271 DECL_REL_OP_T(op,const sc_uint_base&) \ 272 DECL_REL_OP_T(op,const sc_signed&) \ 273 DECL_REL_OP_T(op,const sc_unsigned&) 275 #define DECL_REL_OP_OTHER(op) 278 #define DECL_REL_OP(op) \ 279 friend bool operator op ( const sc_fxval&, const sc_fxval& ); \ 280 DECL_REL_OP_T(op,int) \ 281 DECL_REL_OP_T(op,unsigned int) \ 282 DECL_REL_OP_T(op,long) \ 283 DECL_REL_OP_T(op,unsigned long) \ 284 DECL_REL_OP_T(op,float) \ 285 DECL_REL_OP_T(op,double) \ 286 DECL_REL_OP_T(op,const char*) \ 287 DECL_REL_OP_T(op,const sc_fxval_fast&) \ 288 DECL_REL_OP_T(op,const sc_fxnum_fast&) \ 289 DECL_REL_OP_OTHER(op) 299 #undef DECL_REL_OP_OTHER 305 #define DECL_ASN_OP_T(op,tp) \ 306 sc_fxval& operator op( tp ); 308 #ifndef SC_FX_EXCLUDE_OTHER 309 #define DECL_ASN_OP_OTHER(op) \ 310 DECL_ASN_OP_T(op,int64) \ 311 DECL_ASN_OP_T(op,uint64) \ 312 DECL_ASN_OP_T(op,const sc_int_base&) \ 313 DECL_ASN_OP_T(op,const sc_uint_base&) \ 314 DECL_ASN_OP_T(op,const sc_signed&) \ 315 DECL_ASN_OP_T(op,const sc_unsigned&) 317 #define DECL_ASN_OP_OTHER(op) 320 #define DECL_ASN_OP(op) \ 321 DECL_ASN_OP_T(op,int) \ 322 DECL_ASN_OP_T(op,unsigned int) \ 323 DECL_ASN_OP_T(op,long) \ 324 DECL_ASN_OP_T(op,unsigned long) \ 325 DECL_ASN_OP_T(op,float) \ 326 DECL_ASN_OP_T(op,double) \ 327 DECL_ASN_OP_T(op,const char*) \ 328 DECL_ASN_OP_T(op,const sc_fxval&) \ 329 DECL_ASN_OP_T(op,const sc_fxval_fast&) \ 330 DECL_ASN_OP_T(op,const sc_fxnum&) \ 331 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \ 332 DECL_ASN_OP_OTHER(op) 342 DECL_ASN_OP_T(>>=,
int)
345 #undef DECL_ASN_OP_OTHER 360 operator double()
const;
365 short to_short()
const;
366 unsigned short to_ushort()
const;
368 unsigned int to_uint()
const;
369 long to_long()
const;
370 unsigned long to_ulong()
const;
371 int64 to_int64()
const;
373 float to_float()
const;
374 double to_double()
const;
386 const std::string to_dec()
const;
387 const std::string to_bin()
const;
388 const std::string to_oct()
const;
389 const std::string to_hex()
const;
395 bool is_zero()
const;
398 bool is_normal()
const;
400 bool rounding_flag()
const;
405 void print( ::std::ostream& = ::std::cout )
const;
406 void scan( ::std::istream& = ::std::cin );
407 void dump( ::std::ostream& = ::std::cout )
const;
411 bool get_bit(
int )
const;
419 void get_type(
int&,
int&,
sc_enc& )
const;
462 #ifndef SC_FX_EXCLUDE_OTHER 474 double get_val()
const;
475 void set_val(
double );
491 #define DECL_BIN_OP_T(op,tp) \ 492 friend const sc_fxval_fast operator op ( const sc_fxval_fast&, tp ); \ 493 friend const sc_fxval_fast operator op ( tp, const sc_fxval_fast& ); 495 #ifndef SC_FX_EXCLUDE_OTHER 496 #define DECL_BIN_OP_OTHER(op) \ 497 DECL_BIN_OP_T(op,int64) \ 498 DECL_BIN_OP_T(op,uint64) \ 499 DECL_BIN_OP_T(op,const sc_int_base&) \ 500 DECL_BIN_OP_T(op,const sc_uint_base&) \ 501 DECL_BIN_OP_T(op,const sc_signed&) \ 502 DECL_BIN_OP_T(op,const sc_unsigned&) 504 #define DECL_BIN_OP_OTHER(op) 507 #define DECL_BIN_OP(op,dummy) \ 508 friend const sc_fxval_fast operator op ( const sc_fxval_fast&, \ 509 const sc_fxval_fast& ); \ 510 DECL_BIN_OP_T(op,int) \ 511 DECL_BIN_OP_T(op,unsigned int) \ 512 DECL_BIN_OP_T(op,long) \ 513 DECL_BIN_OP_T(op,unsigned long) \ 514 DECL_BIN_OP_T(op,float) \ 515 DECL_BIN_OP_T(op,double) \ 516 DECL_BIN_OP_T(op,const char*) \ 517 DECL_BIN_OP_OTHER(op) 524 friend const sc_fxval_fast
operator / (
const sc_fxval_fast&,
525 const sc_fxval_fast& );
534 #ifndef SC_FX_EXCLUDE_OTHER 537 DECL_BIN_OP_T(/,
const sc_int_base&) \
538 DECL_BIN_OP_T(/,
const sc_uint_base&) \
539 DECL_BIN_OP_T(/,
const sc_signed&) \
540 DECL_BIN_OP_T(/,
const sc_unsigned&)
544 #undef DECL_BIN_OP_OTHER 553 #define DECL_BIN_FNC_T(fnc,tp) \ 554 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, tp ); \ 555 friend void fnc ( sc_fxval_fast&, tp, const sc_fxval_fast& ); 557 #ifndef SC_FX_EXCLUDE_OTHER 558 #define DECL_BIN_FNC_OTHER(fnc) \ 559 DECL_BIN_FNC_T(fnc,int64) \ 560 DECL_BIN_FNC_T(fnc,uint64) \ 561 DECL_BIN_FNC_T(fnc,const sc_int_base&) \ 562 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \ 563 DECL_BIN_FNC_T(fnc,const sc_signed&) \ 564 DECL_BIN_FNC_T(fnc,const sc_unsigned&) 566 #define DECL_BIN_FNC_OTHER(fnc) 569 #define DECL_BIN_FNC(fnc) \ 570 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, \ 571 const sc_fxval_fast& ); \ 572 DECL_BIN_FNC_T(fnc,int) \ 573 DECL_BIN_FNC_T(fnc,unsigned int) \ 574 DECL_BIN_FNC_T(fnc,long) \ 575 DECL_BIN_FNC_T(fnc,unsigned long) \ 576 DECL_BIN_FNC_T(fnc,float) \ 577 DECL_BIN_FNC_T(fnc,double) \ 578 DECL_BIN_FNC_T(fnc,const char*) \ 579 DECL_BIN_FNC_T(fnc,const sc_fxval&) \ 580 DECL_BIN_FNC_T(fnc,const sc_fxnum&) \ 581 DECL_BIN_FNC_OTHER(fnc) 588 #undef DECL_BIN_FNC_T 589 #undef DECL_BIN_FNC_OTHER 592 friend void lshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
593 friend void rshift( sc_fxval_fast&,
const sc_fxval_fast&,
int );
598 #define DECL_REL_OP_T(op,tp) \ 599 friend bool operator op ( const sc_fxval_fast&, tp ); \ 600 friend bool operator op ( tp, const sc_fxval_fast& ); 602 #ifndef SC_FX_EXCLUDE_OTHER 603 #define DECL_REL_OP_OTHER(op) \ 604 DECL_REL_OP_T(op,int64) \ 605 DECL_REL_OP_T(op,uint64) \ 606 DECL_REL_OP_T(op,const sc_int_base&) \ 607 DECL_REL_OP_T(op,const sc_uint_base&) \ 608 DECL_REL_OP_T(op,const sc_signed&) \ 609 DECL_REL_OP_T(op,const sc_unsigned&) 611 #define DECL_REL_OP_OTHER(op) 614 #define DECL_REL_OP(op) \ 615 friend bool operator op ( const sc_fxval_fast&, const sc_fxval_fast& ); \ 616 DECL_REL_OP_T(op,int) \ 617 DECL_REL_OP_T(op,unsigned int) \ 618 DECL_REL_OP_T(op,long) \ 619 DECL_REL_OP_T(op,unsigned long) \ 620 DECL_REL_OP_T(op,float) \ 621 DECL_REL_OP_T(op,double) \ 622 DECL_REL_OP_T(op,const char*) \ 623 DECL_REL_OP_OTHER(op) 633 #undef DECL_REL_OP_OTHER 639 #define DECL_ASN_OP_T(op,tp) \ 640 sc_fxval_fast& operator op( tp ); 642 #ifndef SC_FX_EXCLUDE_OTHER 643 #define DECL_ASN_OP_OTHER(op) \ 644 DECL_ASN_OP_T(op,int64) \ 645 DECL_ASN_OP_T(op,uint64) \ 646 DECL_ASN_OP_T(op,const sc_int_base&) \ 647 DECL_ASN_OP_T(op,const sc_uint_base&) \ 648 DECL_ASN_OP_T(op,const sc_signed&) \ 649 DECL_ASN_OP_T(op,const sc_unsigned&) 651 #define DECL_ASN_OP_OTHER(op) 654 #define DECL_ASN_OP(op) \ 655 DECL_ASN_OP_T(op,int) \ 656 DECL_ASN_OP_T(op,unsigned int) \ 657 DECL_ASN_OP_T(op,long) \ 658 DECL_ASN_OP_T(op,unsigned long) \ 659 DECL_ASN_OP_T(op,float) \ 660 DECL_ASN_OP_T(op,double) \ 661 DECL_ASN_OP_T(op,const char*) \ 662 DECL_ASN_OP_T(op,const sc_fxval&) \ 663 DECL_ASN_OP_T(op,const sc_fxval_fast&) \ 664 DECL_ASN_OP_T(op,const sc_fxnum&) \ 665 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \ 666 DECL_ASN_OP_OTHER(op) 676 DECL_ASN_OP_T(>>=,
int)
679 #undef DECL_ASN_OP_OTHER 685 const sc_fxval_fast operator ++ (
int );
686 const sc_fxval_fast operator -- (
int );
688 sc_fxval_fast& operator ++ ();
689 sc_fxval_fast& operator -- ();
694 operator double()
const;
699 short to_short()
const;
700 unsigned short to_ushort()
const;
702 unsigned int to_uint()
const;
703 long to_long()
const;
704 unsigned long to_ulong()
const;
705 int64 to_int64()
const;
707 float to_float()
const;
708 double to_double()
const;
720 const std::string to_dec()
const;
721 const std::string to_bin()
const;
722 const std::string to_oct()
const;
723 const std::string to_hex()
const;
729 bool is_zero()
const;
732 bool is_normal()
const;
734 bool rounding_flag()
const;
739 void print( ::std::ostream& = ::std::cout )
const;
740 void scan( ::std::istream& = ::std::cin );
741 void dump( ::std::ostream& = ::std::cout )
const;
745 bool get_bit(
int )
const;
749 sc_fxval_fast_observer* lock_observer()
const;
750 void unlock_observer( sc_fxval_fast_observer* )
const;
753 static double from_string(
const char* );
759 mutable sc_fxval_fast_observer* m_observer;
785 : m_rep( a != 0 ? a : new
scfx_rep ),
795 m_observer( observer_ )
804 : m_rep( new
scfx_rep( *a.m_rep ) ),
805 m_observer( observer_ )
813 #define DEFN_CTOR_T(tp,arg) \ 815 sc_fxval::sc_fxval( tp a, \ 816 sc_fxval_observer* observer_ ) \ 817 : m_rep( new scfx_rep( arg ) ), \ 818 m_observer( observer_ ) \ 820 SC_FXVAL_OBSERVER_DEFAULT_ \ 821 SC_FXVAL_OBSERVER_CONSTRUCT_( *this ) \ 822 SC_FXVAL_OBSERVER_WRITE_( *this ) \ 825 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a) 826 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,a.to_double()) 827 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.value()) 837 #ifndef SC_FX_EXCLUDE_OTHER 914 #define DEFN_BIN_OP_T(op,fnc,tp) \ 917 operator op ( const sc_fxval& a, tp b ) \ 919 SC_FXVAL_OBSERVER_READ_( a ) \ 921 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) ); \ 926 operator op ( tp a, const sc_fxval& b ) \ 928 SC_FXVAL_OBSERVER_READ_( b ) \ 930 return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) ); \ 933 #ifndef SC_FX_EXCLUDE_OTHER 934 #define DEFN_BIN_OP_OTHER(op,fnc) \ 935 DEFN_BIN_OP_T(op,fnc,int64) \ 936 DEFN_BIN_OP_T(op,fnc,uint64) \ 937 DEFN_BIN_OP_T(op,fnc,const sc_int_base&) \ 938 DEFN_BIN_OP_T(op,fnc,const sc_uint_base&) \ 939 DEFN_BIN_OP_T(op,fnc,const sc_signed&) \ 940 DEFN_BIN_OP_T(op,fnc,const sc_unsigned&) 942 #define DEFN_BIN_OP_OTHER(op,fnc) 945 #define DEFN_BIN_OP(op,fnc) \ 948 operator op ( const sc_fxval& a, const sc_fxval& b ) \ 950 SC_FXVAL_OBSERVER_READ_( a ) \ 951 SC_FXVAL_OBSERVER_READ_( b ) \ 952 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \ 955 DEFN_BIN_OP_T(op,fnc,int) \ 956 DEFN_BIN_OP_T(op,fnc,unsigned int) \ 957 DEFN_BIN_OP_T(op,fnc,long) \ 958 DEFN_BIN_OP_T(op,fnc,unsigned long) \ 959 DEFN_BIN_OP_T(op,fnc,float) \ 960 DEFN_BIN_OP_T(op,fnc,double) \ 961 DEFN_BIN_OP_T(op,fnc,const char*) \ 962 DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&) \ 963 DEFN_BIN_OP_OTHER(op,fnc) 988 #ifndef SC_FX_EXCLUDE_OTHER 998 #undef DEFN_BIN_OP_OTHER 1021 #define DEFN_BIN_FNC_T(fnc,tp) \ 1024 fnc ( sc_fxval& c, const sc_fxval& a, tp b ) \ 1026 SC_FXVAL_OBSERVER_READ_( a ) \ 1027 sc_fxval tmp( b ); \ 1029 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ); \ 1030 SC_FXVAL_OBSERVER_WRITE_( c ) \ 1035 fnc ( sc_fxval& c, tp a, const sc_fxval& b ) \ 1037 SC_FXVAL_OBSERVER_READ_( b ) \ 1038 sc_fxval tmp( a ); \ 1040 c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ); \ 1041 SC_FXVAL_OBSERVER_WRITE_( c ) \ 1044 #ifndef SC_FX_EXCLUDE_OTHER 1045 #define DEFN_BIN_FNC_OTHER(fnc) \ 1046 DEFN_BIN_FNC_T(fnc,int64) \ 1047 DEFN_BIN_FNC_T(fnc,uint64) \ 1048 DEFN_BIN_FNC_T(fnc,const sc_int_base&) \ 1049 DEFN_BIN_FNC_T(fnc,const sc_uint_base&) \ 1050 DEFN_BIN_FNC_T(fnc,const sc_signed&) \ 1051 DEFN_BIN_FNC_T(fnc,const sc_unsigned&) 1053 #define DEFN_BIN_FNC_OTHER(fnc) 1056 #define DEFN_BIN_FNC(fnc) \ 1059 fnc( sc_fxval& c, const sc_fxval& a, const sc_fxval& b ) \ 1061 SC_FXVAL_OBSERVER_READ_( a ) \ 1062 SC_FXVAL_OBSERVER_READ_( b ) \ 1064 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ); \ 1065 SC_FXVAL_OBSERVER_WRITE_( c ) \ 1068 DEFN_BIN_FNC_T(fnc,int) \ 1069 DEFN_BIN_FNC_T(fnc,unsigned int) \ 1070 DEFN_BIN_FNC_T(fnc,long) \ 1071 DEFN_BIN_FNC_T(fnc,unsigned long) \ 1072 DEFN_BIN_FNC_T(fnc,float) \ 1073 DEFN_BIN_FNC_T(fnc,double) \ 1074 DEFN_BIN_FNC_T(fnc,const char*) \ 1075 DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&) \ 1076 DEFN_BIN_FNC_OTHER(fnc) 1083 #undef DEFN_BIN_FNC_T 1084 #undef DEFN_BIN_FNC_OTHER 1111 #define DEFN_REL_OP_T(op,ret,tp) \ 1114 operator op ( const sc_fxval& a, tp b ) \ 1116 SC_FXVAL_OBSERVER_READ_( a ) \ 1117 sc_fxval tmp( b ); \ 1118 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep ); \ 1124 operator op ( tp a, const sc_fxval& b ) \ 1126 SC_FXVAL_OBSERVER_READ_( b ) \ 1127 sc_fxval tmp( a ); \ 1128 int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep ); \ 1132 #ifndef SC_FX_EXCLUDE_OTHER 1133 #define DEFN_REL_OP_OTHER(op,ret) \ 1134 DEFN_REL_OP_T(op,ret,int64) \ 1135 DEFN_REL_OP_T(op,ret,uint64) \ 1136 DEFN_REL_OP_T(op,ret,const sc_int_base&) \ 1137 DEFN_REL_OP_T(op,ret,const sc_uint_base&) \ 1138 DEFN_REL_OP_T(op,ret,const sc_signed&) \ 1139 DEFN_REL_OP_T(op,ret,const sc_unsigned&) 1141 #define DEFN_REL_OP_OTHER(op,ret) 1144 #define DEFN_REL_OP(op,ret) \ 1147 operator op ( const sc_fxval& a, const sc_fxval& b) \ 1149 SC_FXVAL_OBSERVER_READ_( a ) \ 1150 SC_FXVAL_OBSERVER_READ_( b ) \ 1151 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep ); \ 1155 DEFN_REL_OP_T(op,ret,int) \ 1156 DEFN_REL_OP_T(op,ret,unsigned int) \ 1157 DEFN_REL_OP_T(op,ret,long) \ 1158 DEFN_REL_OP_T(op,ret,unsigned long) \ 1159 DEFN_REL_OP_T(op,ret,float) \ 1160 DEFN_REL_OP_T(op,ret,double) \ 1161 DEFN_REL_OP_T(op,ret,const char*) \ 1162 DEFN_REL_OP_T(op,ret,const sc_fxval_fast&) \ 1163 DEFN_REL_OP_OTHER(op,ret) 1172 #undef DEFN_REL_OP_T 1173 #undef DEFN_REL_OP_OTHER 1181 sc_fxval::operator = (
const sc_fxval& a )
1192 #define DEFN_ASN_OP_T(tp) \ 1195 sc_fxval::operator = ( tp b ) \ 1197 sc_fxval tmp( b ); \ 1198 *m_rep = *tmp.m_rep; \ 1199 SC_FXVAL_OBSERVER_WRITE_( *this ) \ 1211 #ifndef SC_FX_EXCLUDE_OTHER 1220 #undef DEFN_ASN_OP_T 1223 #define DEFN_ASN_OP_T(op,fnc,tp) \ 1226 sc_fxval::operator op ( tp b ) \ 1228 SC_FXVAL_OBSERVER_READ_( *this ) \ 1229 sc_fxval tmp( b ); \ 1230 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep ); \ 1233 SC_FXVAL_OBSERVER_WRITE_( *this ) \ 1237 #ifndef SC_FX_EXCLUDE_OTHER 1238 #define DEFN_ASN_OP_OTHER(op,fnc) \ 1239 DEFN_ASN_OP_T(op,fnc,int64) \ 1240 DEFN_ASN_OP_T(op,fnc,uint64) \ 1241 DEFN_ASN_OP_T(op,fnc,const sc_int_base&) \ 1242 DEFN_ASN_OP_T(op,fnc,const sc_uint_base&) \ 1243 DEFN_ASN_OP_T(op,fnc,const sc_signed&) \ 1244 DEFN_ASN_OP_T(op,fnc,const sc_unsigned&) 1246 #define DEFN_ASN_OP_OTHER(op,fnc) 1249 #define DEFN_ASN_OP(op,fnc) \ 1252 sc_fxval::operator op ( const sc_fxval& b ) \ 1254 SC_FXVAL_OBSERVER_READ_( *this ) \ 1255 SC_FXVAL_OBSERVER_READ_( b ) \ 1256 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep ); \ 1259 SC_FXVAL_OBSERVER_WRITE_( *this ) \ 1263 DEFN_ASN_OP_T(op,fnc,int) \ 1264 DEFN_ASN_OP_T(op,fnc,unsigned int) \ 1265 DEFN_ASN_OP_T(op,fnc,long) \ 1266 DEFN_ASN_OP_T(op,fnc,unsigned long) \ 1267 DEFN_ASN_OP_T(op,fnc,float) \ 1268 DEFN_ASN_OP_T(op,fnc,double) \ 1269 DEFN_ASN_OP_T(op,fnc,const char*) \ 1270 DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&) \ 1271 DEFN_ASN_OP_OTHER(op,fnc) 1278 #undef DEFN_ASN_OP_T 1279 #undef DEFN_ASN_OP_OTHER 1285 sc_fxval::operator <<= (
int b )
1295 sc_fxval::operator >>= (
int b )
1344 sc_fxval::operator double()
const 1358 return static_cast<short>( m_rep->
to_uint64() );
1366 return static_cast<unsigned short>( m_rep->
to_uint64() );
1374 return static_cast<int>( m_rep->
to_uint64() );
1390 return static_cast<unsigned int>( m_rep->
to_uint64() );
1406 return static_cast<long>( m_rep->
to_uint64() );
1414 return static_cast<unsigned long>( m_rep->
to_uint64() );
1422 return static_cast<float>( m_rep->
to_double() );
1557 m_observer( observer_ )
1567 m_observer( observer_ )
1575 #define DEFN_CTOR_T(tp,arg) \ 1577 sc_fxval_fast::sc_fxval_fast( tp a, \ 1578 sc_fxval_fast_observer* observer_ ) \ 1580 m_observer( observer_ ) \ 1582 SC_FXVAL_FAST_OBSERVER_DEFAULT_ \ 1583 SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this ) \ 1584 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \ 1587 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a )) 1588 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,from_string( a )) 1589 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double()) 1599 #ifndef SC_FX_EXCLUDE_OTHER 1609 #undef DEFN_CTOR_T_A 1610 #undef DEFN_CTOR_T_B 1611 #undef DEFN_CTOR_T_C 1612 #undef DEFN_CTOR_T_D 1613 #undef DEFN_CTOR_T_E 1668 c.m_val = - a.m_val;
1675 #define DEFN_BIN_OP_T(op,tp) \ 1677 const sc_fxval_fast \ 1678 operator op ( const sc_fxval_fast& a, tp b ) \ 1680 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1681 sc_fxval_fast tmp( b ); \ 1682 return sc_fxval_fast( a.m_val op tmp.m_val ); \ 1686 const sc_fxval_fast \ 1687 operator op ( tp a, const sc_fxval_fast& b ) \ 1689 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1690 sc_fxval_fast tmp( a ); \ 1691 return sc_fxval_fast( tmp.m_val op b.m_val ); \ 1694 #ifndef SC_FX_EXCLUDE_OTHER 1695 #define DEFN_BIN_OP_OTHER(op) \ 1696 DEFN_BIN_OP_T(op,int64) \ 1697 DEFN_BIN_OP_T(op,uint64) \ 1698 DEFN_BIN_OP_T(op,const sc_int_base&) \ 1699 DEFN_BIN_OP_T(op,const sc_uint_base&) \ 1700 DEFN_BIN_OP_T(op,const sc_signed&) \ 1701 DEFN_BIN_OP_T(op,const sc_unsigned&) 1703 #define DEFN_BIN_OP_OTHER(op) 1706 #define DEFN_BIN_OP(op,dummy) \ 1708 const sc_fxval_fast \ 1709 operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \ 1711 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1712 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1713 return sc_fxval_fast( a.m_val op b.m_val ); \ 1716 DEFN_BIN_OP_T(op,int) \ 1717 DEFN_BIN_OP_T(op,unsigned int) \ 1718 DEFN_BIN_OP_T(op,long) \ 1719 DEFN_BIN_OP_T(op,unsigned long) \ 1720 DEFN_BIN_OP_T(op,float) \ 1721 DEFN_BIN_OP_T(op,double) \ 1722 DEFN_BIN_OP_T(op,const char*) \ 1723 DEFN_BIN_OP_OTHER(op) 1746 #ifndef SC_FX_EXCLUDE_OTHER 1756 #undef DEFN_BIN_OP_T 1757 #undef DEFN_BIN_OP_OTHER 1780 #define DEFN_BIN_FNC_T(fnc,op,tp) \ 1783 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b ) \ 1785 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1786 sc_fxval_fast tmp( b ); \ 1787 c.m_val = a.m_val op tmp.m_val; \ 1788 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \ 1793 fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b ) \ 1795 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1796 sc_fxval_fast tmp( a ); \ 1797 c.m_val = tmp.m_val op b.m_val; \ 1798 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \ 1801 #ifndef SC_FX_EXCLUDE_OTHER 1802 #define DEFN_BIN_FNC_OTHER(fnc,op) \ 1803 DEFN_BIN_FNC_T(fnc,op,int64) \ 1804 DEFN_BIN_FNC_T(fnc,op,uint64) \ 1805 DEFN_BIN_FNC_T(fnc,op,const sc_int_base&) \ 1806 DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&) \ 1807 DEFN_BIN_FNC_T(fnc,op,const sc_signed&) \ 1808 DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&) 1810 #define DEFN_BIN_FNC_OTHER(fnc,op) 1813 #define DEFN_BIN_FNC(fnc,op) \ 1816 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxval_fast& b ) \ 1818 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1819 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1820 c.m_val = a.m_val op b.m_val; \ 1821 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \ 1824 DEFN_BIN_FNC_T(fnc,op,int) \ 1825 DEFN_BIN_FNC_T(fnc,op,unsigned int) \ 1826 DEFN_BIN_FNC_T(fnc,op,long) \ 1827 DEFN_BIN_FNC_T(fnc,op,unsigned long) \ 1828 DEFN_BIN_FNC_T(fnc,op,float) \ 1829 DEFN_BIN_FNC_T(fnc,op,double) \ 1830 DEFN_BIN_FNC_T(fnc,op,const char*) \ 1831 DEFN_BIN_FNC_OTHER(fnc,op) 1838 #undef DEFN_BIN_FNC_T 1839 #undef DEFN_BIN_FNC_OTHER 1864 #define DEFN_REL_OP_T(op,tp) \ 1867 operator op ( const sc_fxval_fast& a, tp b ) \ 1869 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1870 sc_fxval_fast tmp( b ); \ 1871 return ( a.m_val op tmp.m_val ); \ 1876 operator op ( tp a, const sc_fxval_fast& b ) \ 1878 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1879 sc_fxval_fast tmp( a ); \ 1880 return ( tmp.m_val op b.m_val ); \ 1883 #ifndef SC_FX_EXCLUDE_OTHER 1884 #define DEFN_REL_OP_OTHER(op) \ 1885 DEFN_REL_OP_T(op,int64) \ 1886 DEFN_REL_OP_T(op,uint64) \ 1887 DEFN_REL_OP_T(op,const sc_int_base&) \ 1888 DEFN_REL_OP_T(op,const sc_uint_base&) \ 1889 DEFN_REL_OP_T(op,const sc_signed&) \ 1890 DEFN_REL_OP_T(op,const sc_unsigned&) 1892 #define DEFN_REL_OP_OTHER(op) 1895 #define DEFN_REL_OP(op) \ 1898 operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \ 1900 SC_FXVAL_FAST_OBSERVER_READ_( a ) \ 1901 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 1902 return ( a.m_val op b.m_val ); \ 1905 DEFN_REL_OP_T(op,int) \ 1906 DEFN_REL_OP_T(op,unsigned int) \ 1907 DEFN_REL_OP_T(op,long) \ 1908 DEFN_REL_OP_T(op,unsigned long) \ 1909 DEFN_REL_OP_T(op,float) \ 1910 DEFN_REL_OP_T(op,double) \ 1911 DEFN_REL_OP_T(op,const char*) \ 1912 DEFN_REL_OP_OTHER(op) 1921 #undef DEFN_REL_OP_T 1922 #undef DEFN_REL_OP_OTHER 1941 #define DEFN_ASN_OP_T(tp) \ 1944 sc_fxval_fast::operator = ( tp a ) \ 1946 sc_fxval_fast tmp( a ); \ 1947 m_val = tmp.m_val; \ 1948 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \ 1960 #ifndef SC_FX_EXCLUDE_OTHER 1969 #undef DEFN_ASN_OP_T 1972 #define DEFN_ASN_OP_T(op,tp) \ 1975 sc_fxval_fast::operator op ( tp b ) \ 1977 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \ 1978 sc_fxval_fast tmp( b ); \ 1979 m_val op tmp.m_val; \ 1980 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \ 1984 #ifndef SC_FX_EXCLUDE_OTHER 1985 #define DEFN_ASN_OP_OTHER(op) \ 1986 DEFN_ASN_OP_T(op,int64) \ 1987 DEFN_ASN_OP_T(op,uint64) \ 1988 DEFN_ASN_OP_T(op,const sc_int_base&) \ 1989 DEFN_ASN_OP_T(op,const sc_uint_base&) \ 1990 DEFN_ASN_OP_T(op,const sc_signed&) \ 1991 DEFN_ASN_OP_T(op,const sc_unsigned&) 1993 #define DEFN_ASN_OP_OTHER(op) 1996 #define DEFN_ASN_OP(op) \ 1999 sc_fxval_fast::operator op ( const sc_fxval_fast& b ) \ 2001 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \ 2002 SC_FXVAL_FAST_OBSERVER_READ_( b ) \ 2004 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \ 2008 DEFN_ASN_OP_T(op,int) \ 2009 DEFN_ASN_OP_T(op,unsigned int) \ 2010 DEFN_ASN_OP_T(op,long) \ 2011 DEFN_ASN_OP_T(op,unsigned long) \ 2012 DEFN_ASN_OP_T(op,float) \ 2013 DEFN_ASN_OP_T(op,double) \ 2014 DEFN_ASN_OP_T(op,const char*) \ 2015 DEFN_ASN_OP_T(op,const sc_fxval&) \ 2016 DEFN_ASN_OP_OTHER(op) 2023 #undef DEFN_ASN_OP_T 2024 #undef DEFN_ASN_OP_OTHER 2030 sc_fxval_fast::operator <<= (
int b )
2040 sc_fxval_fast::operator >>= (
int b )
2099 sc_fxval_fast::operator double()
const 2113 return static_cast<short>(
to_uint64() );
2121 return static_cast<unsigned short>(
to_uint64() );
2145 return static_cast<unsigned int>(
to_uint64() );
2159 double mantissa_dbl = frexp(m_val, &exponent);
2164 if (!(-64 < exponent && exponent < 64))
2169 mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
2170 return mantissa_dbl >= 0 ? mantissa : -mantissa;
2178 return static_cast<long>(
to_uint64() );
2186 return static_cast<unsigned long>(
to_uint64() );
2194 return static_cast<float>( m_val );
2214 return (
id.negative() != 0 );
2223 return id.is_zero();
2281 #undef SCFX_EXPLICIT_ 2282 #undef SCFX_EXPLICIT_OTHER_ SC_API sc_signed operator-(const sc_unsigned &u, const sc_signed &v)
Base class for the fixed-point types; limited precision.
const sc_fxval_fast & operator+() const
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define DEFN_CTOR_T_A(tp)
#define DEFN_REL_OP(op, ret)
Fixed-point value types; limited precision.
Convenient interface to union ieee_double.
Arbitrary precision signed arithmetic.
bool rounding_flag() const
sc_enc
Enumeration of sign encodings.
unsigned short to_ushort() const
void print(::std::ostream &=::std::cout) const
friend const sc_fxval operator/(const sc_fxval &, const sc_fxval &)
void get_type(int &, int &, sc_enc &) const
unsigned int to_uint() const
friend const sc_fxval_fast operator>>(const sc_fxval_fast &, int)
void neg(sc_fxval &c, const sc_fxnum &a)
#define DECL_BIN_OP_T(op, tp)
sc_fxval_fast(sc_fxval_fast_observer *=0)
unsigned int to_uint() const
Arbitrary precision signed number.
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
#define DEFN_CTOR_T_C(tp)
#define SC_FXVAL_OBSERVER_READ_(object)
Arbitrary precision unsigned number.
friend const sc_fxval_fast operator/(const sc_fxval_fast &, const sc_fxval_fast &)
Base class for the fixed-point types; arbitrary precision.
double scfx_pow2(int exp)
Computes 2.
uint64 const sc_uint_base int b
unsigned short to_ushort() const
#define SCFX_EXPLICIT_OTHER_
DEFN_BIN_OP_T(/, div, int64) DEFN_BIN_OP_T(/
sc_fxval_observer * observer() const
void scan(::std::istream &=::std::cin)
const sc_fxval operator/(const sc_fxnum &a, const sc_fxnum &b)
#define DECL_BIN_FNC(fnc)
friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int)
Abstract base class for fixed-point value type observers;.
friend void rshift(sc_fxval &, const sc_fxval &, int)
Fixed-point value type; arbitrary precision.
An unsigned integer whose length is less than 64 bits.
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Arbitrary-precision fixed-point implementation class.
sc_fxval_fast_observer * observer() const
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
SC_API sc_signed operator+(const sc_unsigned &u, const sc_signed &v)
sc_fxval_fast & operator++()
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
Arbitrary precision unsigned arithmetic.
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
void print(::std::ostream &=::std::cout) const
friend void neg(sc_fxval &, const sc_fxval &)
const sc_fxval quantization(const scfx_params &, bool &) const
sc_fmt
Enumeration of formats for character string conversion.
SC_API const std::string to_string(sc_enc)
Abstract base class for fixed-point value type observers;.
SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
#define DEFN_ASN_OP(op, fnc)
sc_numrep
Enumeration of number representations for character string conversion.
#define DECL_BIN_OP(op, dummy)
const sc_fxval & operator+() const
friend void lshift(sc_fxval &, const sc_fxval &, int)
#define DEFN_CTOR_T_B(tp)
unsigned long to_ulong() const
const sc_fxval operator-() const
#define DEFN_ASN_OP_T(tp)
friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int)
const sc_fxval overflow(const scfx_params &, bool &) const
unsigned long to_ulong() const
const scfx_rep * get_rep() const
bool rounding_flag() const
#define SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
#define DECL_ASN_OP_T(op, tp)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
SC_API scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
sc_fxval_fast & operator--()
#define DEFN_BIN_FNC(fnc)
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
void get_type(int &, int &, sc_enc &) const
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
const sc_fxval_fast operator-() const
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
#define DEFN_BIN_OP(op, fnc)
void scan(::std::istream &=::std::cin)
bool rounding_flag() const
friend void neg(sc_fxval_fast &, const sc_fxval_fast &)
A signed integer whose length is less than 64 bit.
inline ::std::istream & operator>>(::std::istream &is, sc_bit &a)
friend const sc_fxval operator>>(const sc_fxval &, int)
static const uint64 UINT64_ONE