MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / encode_decimal128

Function encode_decimal128

examples/src/bson_examples.cpp:257–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257void encode_decimal128()
258{
259 json j;
260
261 j.try_emplace("a", "1E-6176", jsoncons::semantic_tag::float128);
262 // or j["a"] = json("1E-6176", jsoncons::semantic_tag::float128);
263
264 std::cout << "(1) " << j << "\n\n";
265 std::cout << "(2) " << j.at("a").tag() << "\n\n";
266
267 std::vector<char> output;
268 bson::encode_bson(j, output);
269 std::cout << "(3) " << jsoncons::byte_string_view(output) << "\n\n";
270 /*
271 18,00,00,00, // document has 24 bytes
272 13, // 128-bit decimal floating point
273 13,00, // "a"
274 01,00,00,00,
275 00,00,00,00, // 1E-6176
276 00,00,00,00,
277 00,00,00,00,
278 00 // terminating null
279 */
280}
281
282void regex_example()
283{

Callers 1

mainFunction · 0.85

Calls 5

encode_bsonFunction · 0.85
byte_string_viewClass · 0.85
atMethod · 0.80
try_emplaceMethod · 0.45
tagMethod · 0.45

Tested by

no test coverage detected