Boost logo

Boost :

From: martin.ecker_at_[hidden]
Date: 2005-08-11 04:52:43


Sorry about the previous, empty e-mail. We were having mail server
problems at my company.
Below is the content of my original mail:

Hello,

The following sample program:

#include <cstdio>
#include <iostream>
#include <limits>
#include <boost/format.hpp>

int main(int argc, char* argv[])
{
        std::cout << boost::format("%f") % std::numeric_limits<float
>::infinity() << std::endl;
        std::printf("%f", std::numeric_limits<float>::infinity());
        return 0;
}

produces
1.00000000000000000000000000....00000000000000000.#INF00
with Boost.Format, but
1.#INF00
with printf.

Is this a bug or shouldn't I expect the same behavior from Boost.Format
for special floating point values such as NaN and
infinity?

Note that using %g instead of %f, that is:
std::cout << boost::format("%g") % std::numeric_limits<float>::infinity()
<< std::endl;
prints the same thing as printf, i.e. 1.#INF00

This is using Boost 1.32.0 with MSVC 7.1 on Windows.

Best Regards,
Martin

TAB Austria
Haiderstraße 40
4052 Ansfelden
Austria
Phone: +43 7229 78040-218
Fax: +43 7229 78040-209
E-mail: martin.ecker_at_[hidden]
http://www.tab.at


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk