From ffeca2a2545ed18e7985235a2190f48f9f2b63f8 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 11 Mar 2021 20:05:59 +0100 Subject: [PATCH] Change comparison to use int instead of double (#1758) This allows the example to remain simple well not misleading a beginner such a comparison is safe. Including an epsilon comparison or something similar would overly complicate this example. Co-authored-by: Martin O'Shea --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 15d2fb0..b76d5e8 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -13945,10 +13945,10 @@ Although `cached_computation` works perfectly in a single-threaded environment, ##### Example, good struct ComputationCache { - double cached_x = 0.0; + int cached_x = 0; double cached_result = COMPUTATION_OF_ZERO; - double compute(double x) { + double compute(int x) { if (cached_x != x) { cached_x = x; cached_result = computation(x);