summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdvait Jain <advaitjain@users.noreply.github.com>2021-12-23 18:31:30 -0800
committerGitHub <noreply@github.com>2021-12-23 20:31:30 -0600
commitf28c2b29364970e23c8ba3d751ca188f8a08c71e (patch)
treef2b8d62b3dc3670d829c22ff7a1f135af4c42731 /include
parent96f3cf690feec0739e57c183b698779ab4d7d0c0 (diff)
downloadflatbuffers-f28c2b29364970e23c8ba3d751ca188f8a08c71e.tar.gz
flatbuffers-f28c2b29364970e23c8ba3d751ca188f8a08c71e.tar.bz2
flatbuffers-f28c2b29364970e23c8ba3d751ca188f8a08c71e.zip
Avoid implicit conversion from float to double. (#7003)
https://github.com/tensorflow/tflite-micro makes use of flatbuffers with a variety of DSP toolchains. Without the change from this PR, we can get a double-promotion warning with some of these DSP toolchains: ``` flatbuffers/include/flatbuffers/util.h:104:11: error: implicit conversion increases floating-point precision: 'std::numeric_limits<float>::_Ty' (aka 'float') to 'double' [-Werror,-Wdouble-promotion] T eps = std::numeric_limits<float>::epsilon(); ~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
Diffstat (limited to 'include')
-rw-r--r--include/flatbuffers/util.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 93a39de1..c0a37b9f 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -95,7 +95,7 @@ template<typename T> size_t IntToDigitCount(T t) {
// Count a single 0 left of the dot for fractional numbers
if (-1 < t && t < 1) digit_count++;
// Count digits until fractional part
- T eps = std::numeric_limits<float>::epsilon();
+ T eps = std::numeric_limits<T>::epsilon();
while (t <= (-1 + eps) || (1 - eps) <= t) {
t /= 10;
digit_count++;