diff --git a/app/src/variant_util.cc b/app/src/variant_util.cc index 8fea2119e7..d8c03dde3d 100644 --- a/app/src/variant_util.cc +++ b/app/src/variant_util.cc @@ -55,7 +55,10 @@ static bool VariantToJson(const Variant& variant, bool prettyPrint, break; } case Variant::kTypeDouble: { - *ss << variant.double_value(); + // IEEE 754 double-precision binary floating-point format: binary64 — The + // 53-bit significand precision gives from 15 to 17 significant decimal + // digits Default 32-bit only keeps 7 digit precision + *ss << std::setprecision(17) << variant.double_value(); break; } case Variant::kTypeBool: { diff --git a/database/integration_test/src/integration_test.cc b/database/integration_test/src/integration_test.cc index 65ad704f3d..ae4e7c68e0 100644 --- a/database/integration_test/src/integration_test.cc +++ b/database/integration_test/src/integration_test.cc @@ -391,6 +391,7 @@ static const int kSimpleInt = 2; static const int kSimplePriority = 100; static const double kSimpleDouble = 3.4; static const bool kSimpleBool = true; +static const double kLongDouble = 0.123456789876543; TEST_F(FirebaseDatabaseTest, TestSetAndGetSimpleValues) { const char* test_name = test_info_->name(); @@ -415,12 +416,15 @@ TEST_F(FirebaseDatabaseTest, TestSetAndGetSimpleValues) { ref.Child(test_name) .Child("IntAndPriority") .SetValueAndPriority(kSimpleInt, kSimplePriority); + firebase::Future f7 = + ref.Child(test_name).Child("LongDouble").SetValue(kLongDouble); WaitForCompletion(f1, "SetSimpleString"); WaitForCompletion(f2, "SetSimpleInt"); WaitForCompletion(f3, "SetSimpleDouble"); WaitForCompletion(f4, "SetSimpleBool"); WaitForCompletion(f5, "SetSimpleTimestamp"); WaitForCompletion(f6, "SetSimpleIntAndPriority"); + WaitForCompletion(f7, "SetLongDouble"); } // Get the values that we just set, and confirm that they match what we @@ -439,12 +443,15 @@ TEST_F(FirebaseDatabaseTest, TestSetAndGetSimpleValues) { ref.Child(test_name).Child("Timestamp").GetValue(); firebase::Future f6 = ref.Child(test_name).Child("IntAndPriority").GetValue(); + firebase::Future f7 = + ref.Child(test_name).Child("LongDouble").GetValue(); WaitForCompletion(f1, "GetSimpleString"); WaitForCompletion(f2, "GetSimpleInt"); WaitForCompletion(f3, "GetSimpleDouble"); WaitForCompletion(f4, "GetSimpleBool"); WaitForCompletion(f5, "GetSimpleTimestamp"); WaitForCompletion(f6, "GetSimpleIntAndPriority"); + WaitForCompletion(f7, "GetLongDouble"); // Get the current time to compare to the Timestamp. int64_t current_time_milliseconds = @@ -458,6 +465,7 @@ TEST_F(FirebaseDatabaseTest, TestSetAndGetSimpleValues) { TimestampIsNear(current_time_milliseconds)); EXPECT_EQ(f6.result()->value().AsInt64(), kSimpleInt); EXPECT_EQ(f6.result()->priority().AsInt64(), kSimplePriority); + EXPECT_EQ(f7.result()->value().AsDouble(), kLongDouble); } } diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 6eabbbd5d8..290918aa6f 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -567,6 +567,10 @@ workflow use only during the development of your app, not for publicly shipping code. ## Release Notes +### Next Release +- Changes + - General: Variant double type now support 64-bit while saving to json. + ([#1133](https://github.com/firebase/quickstart-unity/issues/1133)). ### 8.6.0 - Changes