Go to the documentation of this file.
100 return std::string(
m_rep->
to_string(numrep, (w_prefix ? 1 : 0), fmt));
144 os <<
"sc_fxval" << ::std::endl;
145 os <<
"(" << ::std::endl;
155 os <<
")" << ::std::endl;
171 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
185 if (
id.negative() != 0) {
201 double frac_part = std::modf(
static_cast<double>(
id), &int_part);
209 if (int_part != 0.0) {
210 int_digits = (int)std::ceil(std::log10(int_part + 1.0));
212 int len =
s.length();
213 s.append(int_digits);
215 bool zero_digits = (frac_part == 0.0 && fmt !=
SC_F);
217 for (
i = int_digits +
len - 1;
i >=
len;
i--) {
218 unsigned int remainder = (
unsigned int)std::fmod(int_part, 10.0);
232 s.discard(int_zeros);
245 if (frac_part != 0.0) {
248 bool zero_digits = (int_digits == 0 && fmt !=
SC_F);
250 frac_zeros = (int)std::floor(-std::log10(frac_part + DBL_EPSILON));
252 frac_part *= std::pow(10.0, frac_zeros);
254 frac_digits = frac_zeros;
256 for (
i = 0;
i < frac_zeros;
i++)
261 while (frac_part != 0.0) {
263 int n =
static_cast<int>(frac_part);
273 s +=
static_cast<char>(
'0' +
n);
282 if (frac_digits == 0)
284 else if (int_digits == 0)
291 int w_prefix,
sc_fmt fmt,
const scfx_params *params)
293 scfx_ieee_double id2 =
id;
297 bool numrep_is_sm = (numrep ==
SC_BIN_SM ||
302 if (id2.negative() != 0) {
327 sc_fxval_fast
a(id2);
332 msb = params->iwl() - 1;
333 lsb = params->iwl() - params->wl();
335 if (params->enc() ==
SC_TC_ &&
342 }
else if (params->enc() ==
SC_US_ &&
354 msb = id2.exponent() + 1;
355 while (
a.get_bit(msb) ==
a.get_bit(msb - 1))
364 lsb = id2.exponent() - 52;
365 while (!
a.get_bit(lsb))
388 "unexpected sc_numrep");
392 msb = (int)std::ceil(
double(msb + 1) / step) * step - 1;
394 lsb = (int)std::floor(
double(lsb) / step) * step;
399 int sign = (id2.negative() != 0) ? (1 << step) - 1 : 0;
400 for (
int i = (msb + 1) / step;
i < 0;
i++) {
402 s +=
static_cast<char>(sign +
'0');
404 s +=
static_cast<char>(sign +
'a' - 10);
412 for (
int j = step - 1;
j >= 0; --
j) {
413 value +=
static_cast<int>(
a.get_bit(
i)) <<
j;
417 s +=
static_cast<char>(value +
'0');
419 s +=
static_cast<char>(value +
'a' - 10);
424 if (lsb > 0 && fmt ==
SC_F) {
425 for (
int i = lsb / step;
i > 0;
i--)
429 if (
s[
s.length() - 1] ==
'.')
445 sc_fmt fmt,
const scfx_params *params=0)
447 static scfx_string
s;
455 }
else if (
id.negative() && !
id.is_zero() &&
460 }
else if (numrep ==
SC_DEC) {
553 os <<
"sc_fxval_fast" << ::std::endl;
554 os <<
"(" << ::std::endl;
555 os <<
"val = " <<
m_val << ::std::endl;
563 os <<
")" << ::std::endl;
576 unsigned int m0 =
id.mantissa0();
577 unsigned int m1 =
id.mantissa1();
582 if (
id.negative() != 0) {
585 unsigned int tmp = m1;
592 int j =
i -
id.exponent();
594 return ((m0 & 1U << 31) != 0);
596 return ((m0 & 1U <<
j) != 0);
597 else if ((
j += 32) >= 0)
598 return ((m1 & 1U <<
j) != 0);
617 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
621 #define SCFX_FAIL_IF_(cnd) \
624 return static_cast<double>(scfx_ieee_double::nan()); \
695 s = (
const char*) s2 + 4;
707 bool based_point =
false;
734 for (
const char *
e = end + 2; *
e;
e++)
736 exponent = std::atoi(end + 1);
742 double integer = 0.0;
743 if (int_digits != 0) {
744 bool first_digit =
true;
746 for (;
s < end;
s++) {
757 if (integer >= (
base >> 1))
773 double fraction = 0.0;
774 if (frac_digits != 0) {
777 bool first_digit = (int_digits == 0);
779 for (;
s < end;
s++) {
789 if (fraction >= (
base >> 1))
805 (exponent != 0) ? std::pow((
double)
base, (double) exponent) : 1;
807 return (sign * (integer + fraction) * exp);
sc_numrep scfx_parse_prefix(const char *&s)
bool scfx_is_digit(char c, sc_numrep numrep)
static double from_string(const char *)
void dump(::std::ostream &=::std::cout) const
const std::string to_oct() const
void unlock_observer(sc_fxval_observer *) const
int scfx_to_digit(char c, sc_numrep numrep)
void scfx_tc2csd(scfx_string &s, int w_prefix)
const std::string to_string(sc_enc enc)
#define SC_REPORT_FATAL(msg_type, msg)
void scfx_print_inf(scfx_string &s, bool negative)
const std::string to_string() const
const std::string to_oct() const
void scan(::std::istream &=::std::cin)
bool scfx_exp_start(const char *s)
static const scfx_ieee_double inf(int)
const std::string to_dec() const
const std::string to_dec() const
const std::string to_hex() const
const std::string to_hex() const
void dump(::std::ostream &) const
void scfx_print_nan(scfx_string &s)
int scfx_parse_sign(const char *&s, bool &sign_char)
sc_fxval_fast_observer * lock_observer() const
#define SCFX_FAIL_IF_(cnd)
sc_fxval_observer * m_observer
const std::string to_bin() const
const char SC_ID_ASSERTION_FAILED_[]
bool scfx_is_inf(const char *s)
void print(::std::ostream &) const
void print(::std::ostream &=::std::cout) const
static void print_dec(scfx_string &s, scfx_ieee_double id, int w_prefix, sc_fmt fmt)
void scfx_print_exp(scfx_string &s, int exp)
void print(::std::ostream &=::std::cout) const
const char * to_string(sc_numrep, int, sc_fmt, const scfx_params *=0) const
sc_fxval_observer * lock_observer() const
const std::string to_bin() const
void unlock_observer(sc_fxval_fast_observer *) const
static void print_other(scfx_string &s, const scfx_ieee_double &id, sc_numrep numrep, int w_prefix, sc_fmt fmt, const scfx_params *params)
void scfx_print_prefix(scfx_string &s, sc_numrep numrep)
bool scfx_is_nan(const char *s)
sc_fxval_fast_observer * m_observer
const std::string to_string() const
static const scfx_ieee_double nan()
void dump(::std::ostream &=::std::cout) const
void scfx_csd2tc(scfx_string &csd)
void scan(::std::istream &=::std::cin)
#define SC_ASSERT_(cnd, msg)
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17