Subject: [Boost-bugs] [Boost C++ Libraries] #9545: program_options description printout bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-06 12:29:02
#9545: program_options description printout bug
------------------------------------------+-----------------------------
Reporter: Torquil Sørensen <torquil@â¦> | Owner: vladimir_prus
Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------------------+-----------------------------
When setting the default value of a float option to 0.05, the help
description that is printed by the program states that the default value
is 0.0500000007. For double, it states "0.050000000000000003". The value
of the variable within the program is correct, i.e. 0.05.
I'm compiling with:
$ g++ --version
g++ (GCC) 4.8.3 20131226 (prerelease)
Here is a test program that reproduces the problem when run with the
option "--help":
{{{
#include "boost/program_options.hpp"
int main(int argc, char ** argv)
{
float dt;
boost::program_options::variables_map vm;
boost::program_options::options_description desc("Description");
desc.add_options()
("help", "Print help message")
("dt",
boost::program_options::value<float>(&dt)->default_value(0.05), "Time
step")
;
boost::program_options::store(boost::program_options::parse_command_line(argc,
argv, desc), vm);
boost::program_options::notify(vm);
if(vm.count("help")) desc.print(std::cout);
std::cout << "dt = " << dt << "\n";
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9545> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC