From 4883245747927cc4d9177dc0d692c47944d3043c Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 30 Jun 2016 18:18:57 -0700 Subject: [PATCH] Use float literals when initializing float values Summary: MSVC was correctly warning that we were initializing `float` variables with `double` literals. This just adds the explicit suffix so they are `float` literals instead. Reviewed By: yfeldblum Differential Revision: D3506797 fbshipit-source-id: 7eb4588958eddb984ba830e2599ac505d495783e --- folly/test/AtomicHashMapTest.cpp | 8 ++++---- folly/test/ConvBenchmark.cpp | 2 +- folly/test/ConvTest.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/folly/test/AtomicHashMapTest.cpp b/folly/test/AtomicHashMapTest.cpp index 9082ddd6..a8c6dff2 100644 --- a/folly/test/AtomicHashMapTest.cpp +++ b/folly/test/AtomicHashMapTest.cpp @@ -181,7 +181,7 @@ TEST(Ahm, grow) { VLOG(1) << "Overhead: " << sizeof(AHArrayT) << " (array) " << sizeof(AHMapT) + sizeof(AHArrayT) << " (map/set) Bytes."; uint64_t numEntries = 10000; - float sizeFactor = 0.46; + float sizeFactor = 0.46f; std::unique_ptr m(new AHMapT(int(numEntries * sizeFactor), config)); @@ -241,7 +241,7 @@ TEST(Ahm, grow) { TEST(Ahm, iterator) { int numEntries = 10000; - float sizeFactor = .46; + float sizeFactor = .46f; std::unique_ptr m(new AHMapT(int(numEntries * sizeFactor), config)); // load map - make sure we succeed and the index is accurate @@ -347,7 +347,7 @@ TEST(Ahm, map_exception_safety) { typedef AtomicHashMap MyMapT; int numEntries = 10000; - float sizeFactor = 0.46; + float sizeFactor = 0.46f; std::unique_ptr m(new MyMapT(int(numEntries * sizeFactor))); bool success = true; @@ -470,7 +470,7 @@ TEST(Ahm, collision_test) { // Doing the same number on each thread so we collide. numOpsPerThread = numInserts; - float sizeFactor = 0.46; + float sizeFactor = 0.46f; int entrySize = sizeof(KeyT) + sizeof(ValueT); VLOG(1) << "Testing " << numInserts << " unique " << entrySize << " Byte entries replicated in " << FLAGS_numThreads << diff --git a/folly/test/ConvBenchmark.cpp b/folly/test/ConvBenchmark.cpp index efff0bf3..a6e21dd2 100644 --- a/folly/test/ConvBenchmark.cpp +++ b/folly/test/ConvBenchmark.cpp @@ -509,7 +509,7 @@ char someString[] = "this is some nice string"; char otherString[] = "this is a long string, so it's not so nice"; char reallyShort[] = "meh"; std::string stdString = "std::strings are very nice"; -float fValue = 1.2355; +float fValue = 1.2355f; double dValue = 345345345.435; } } diff --git a/folly/test/ConvTest.cpp b/folly/test/ConvTest.cpp index 4bbca6da..5512014c 100644 --- a/folly/test/ConvTest.cpp +++ b/folly/test/ConvTest.cpp @@ -81,7 +81,7 @@ TEST(Conv, Type2Type) { int intV = 42; EXPECT_EQ(to(intV), 42); - float floatV = 4.2; + float floatV = 4.2f; EXPECT_EQ(to(floatV), 4.2f); double doubleV = 0.42; @@ -117,7 +117,7 @@ TEST(Conv, Integral2Integral) { } TEST(Conv, Floating2Floating) { - float f1 = 1e3; + float f1 = 1e3f; double d1 = to(f1); EXPECT_EQ(f1, d1); -- 2.34.1