While experimenting with the C++11 driver of MongoDB (version 3.1.0-rc0) the output of the following piece of code confused me.
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
int main() {
bsoncxx::builder::stream::document s;
s << "x" << 1.0
<< "y" << 0.999999
<< "z" << 0.9999999;
std::cout << bsoncxx::to_json(s) << std::endl;
return 0;
}
Output:
{
"x" : 1,
"y" : 0.999999,
"z" : 1
}
- Is this the expected behavior?
- How can I make sure that BSON doubles are represented as floating point numbers in JSON?
- How can I set the desired precision?
Aucun commentaire:
Enregistrer un commentaire