Printing out mpf_class inside gdb

Stephen torri storri at torri.org
Mon Jul 19 03:56:20 CEST 2004


On Sun, 2004-07-18 at 18:44, Kevin Ryde wrote:
> Stephen torri <storri at torri.org> writes:
> >
> > Simply add a delimeter to the end, \0 , to every
> > mpf_class type when written to a file.
> 
> Yes, but you have to do that yourself.  GMP c++ output follows the c++
> output conventions, and the input follows the c++ float parsing
> conventions.  You need some sort of separator in the output to
> disambiguate when reading back.
> 
> A NUL character is probably not a good idea if it's going to be a text
> file, a space or newline may be better.  Input will skip leading
> whitespace if the ios::skipws flag is set (I'm not sure if that's the
> default).

We open our files in binary mode:

        m_file_handle.open(m_file_ref->get_Full_Name().c_str(),
                           std::ofstream::binary);

So I think a NUL character is fine. In regards to the C++ output
convention is that is the C++ standard or merely just the common
practice among implementations?

In regards to ios::skipws that is not on by default. When I had a
formatted string written to the file, "Crazy Kittens", I would get back
Crazy if I did turn ios::skipws on.

Stephen



More information about the gmp-bugs mailing list