I'm using the mongocxx (v3) driver in my project to store the app settings in the mongodb. While working in windows everything seems to work well. But now that i'm testing in linux i have noticed some problems that i cannot understand why are happening.
i have the following function to retrieve the app settings:
QJsonObject MongoDBManager::getProjectsSettings(QString appid,QString projectsname)
{
try {
if(m_selectedDB.has_collection(projectsname.toStdString())==false){
LOG_ERROR()<<"collection '"+projectsname+"' do not exist";
return QJsonObject();
}
mongocxx::collection selectedCollection = m_selectedDB[projectsname.toStdString()];
auto cursor =selectedCollection.find(document{}
<< "appid"
<< appid.toStdString()
<< finalize
);
// auto cursor = m_selectedCollection.find(document{} << "_id" << appid.toStdString() << finalize);
for (auto &&doc : cursor) {
bsoncxx::builder::stream::document s;
s << "x" << 1.0;
std::cout<<"testing:" << bsoncxx::to_json(s) << std::endl;
std::cout<<"doc:"<< bsoncxx::to_json(doc)<<std::endl;
....
While in run in debug mode i get the following output:
testing:{ "x" : 1.0 }
doc:{ "_id" : { "$oid" : "5e94da26ef664e37b0d8d1e4" }, "appid" : "5ea8a4192483621670ffeb2b", "value" : 1.1000000000000000888 }
and in release i get:
testing:{ "x" : 1.0 }
doc:{ "_id" : { "$oid" : "5e94da26ef664e37b0d8d1e4" }, "appid" : "5ea8a4192483621670ffeb2b", "value" : 1,1000000000000000888 }
I have to strange things happening:
In debug mode i have a valid json document
... "value" : 1.1000000000000000888 }
but in release mode i have comma instead of dots in the decimal separator witch obviously is an invalid JSON document.
... "value" : 1,1000000000000000888 }
In the DB i have 1.1 why i'm getting 1.1000000000000000888 in my program