diff --git a/Packages/Core/include/CORE/BigRat.h b/Packages/Core/include/CORE/BigRat.h index 44d2812fcb4..7a75438b72d 100644 --- a/Packages/Core/include/CORE/BigRat.h +++ b/Packages/Core/include/CORE/BigRat.h @@ -308,9 +308,13 @@ public: return mpq_set_str(get_mp(), s, base); } /// convert to std::string - std::string get_str(int base = 10) const { - _alloc_cstr t(mpq_get_str(0, base, get_mp())); - return std::string(t.str); + std::string get_str(int base Bi= 10) const { + int n = mpz_sizeinbase(mpq_numref(get_mp()), base) + mpz_sizeinbase(mpq_denref(get_mp()), base)+ 3; + char *buffer = new char[n]; + mpq_get_str(buffer, base, get_mp()); + std::string result(buffer); + delete [] buffer; + return result; } //@}