Macaulay2 Engine
Loading...
Searching...
No Matches

◆ operator=() [12/15]

mpreal & mpfr::mpreal::operator= ( const std::string & s)
inline

Definition at line 1089 of file mpreal.h.

1090{
1091 // Use other converters for more precise control on base & precision & rounding:
1092 //
1093 // mpreal(const char* s, mp_prec_t prec, int base, mp_rnd_t mode)
1094 // mpreal(const std::string& s,mp_prec_t prec, int base, mp_rnd_t mode)
1095 //
1096 // Here we assume base = 10 and we use precision of target variable.
1097
1098 mpfr_t t;
1099
1100 mpfr_init2(t, mpfr_get_prec(mpfr_srcptr()));
1101
1102 if(0 == mpfr_set_str(t, s.c_str(), 10, mpreal::get_default_rnd()))
1103 {
1104 mpfr_set(mpfr_ptr(), t, mpreal::get_default_rnd());
1106 }
1107
1108 clear(t);
1109 return *this;
1110}
MPREAL_MSVC_DEBUGVIEW_DATA void clear(::mpfr_ptr)
Definition mpreal.h:770
::mpfr_srcptr mpfr_srcptr() const
Definition mpreal.h:1767
::mpfr_ptr mpfr_ptr()
Definition mpreal.h:1765
void size_t s
Definition m2-mem.cpp:271
#define MPREAL_MSVC_DEBUGVIEW_CODE
Definition mpreal.h:146

References clear(), get_default_rnd(), mpfr_ptr(), mpfr_srcptr(), mpreal(), MPREAL_MSVC_DEBUGVIEW_CODE, operator=(), and s.