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

Function bignum_access_examples

examples_boost/serialization_examples.cpp:394–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394void bignum_access_examples()
395{
396 std::string input = "-18446744073709551617";
397
398 json j = json::parse(input);
399
400 // Access as string
401 std::string s = j.as<std::string>();
402 std::cout << "(1) " << s << "\n\n";
403
404 // Access as double
405 double d = j.as<double>();
406 std::cout << "(2) " << std::setprecision(17) << d << "\n\n";
407
408 // Access as jsoncons::bigint
409 jsoncons::bigint bn = j.as<jsoncons::bigint>();
410 std::cout << "(3) " << bn << "\n\n";
411
412 // If your compiler supports extended integral types
413#if (defined(__GNUC__) || defined(__clang__)) && defined(JSONCONS_HAS_INT128)
414 __int128 i = j.as<__int128>();
415 boost_mp::int128_t boost_i = static_cast<boost_mp::int128_t>(i);
416 std::cout << "(4) " << boost_i << "\n\n";
417#endif
418}
419
420void decimal_precision_examples()
421{

Callers 1

mainFunction · 0.85

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected