Skip to content

Commit

Permalink
remove use of == on doubles
Browse files Browse the repository at this point in the history
could use an epsilon, but that just distracts from the point of the example, so changed double to int instead
  • Loading branch information
tvaneerd committed Mar 22, 2016
1 parent 7a8cac8 commit 7a4fbef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -10211,15 +10211,13 @@ Note that this applies most urgently to library code and least urgently to stand

##### Example

double cached_computation(double x)
double cached_computation(int x)
{
static double cached_x = 0.0;
static int cached_x = 0;
static double cached_result = COMPUTATION_OF_ZERO;
double result;

if (cached_x == x)
return cached_result;
result = computation(x);
double result = computation(x);
cached_x = x;
cached_result = result;
return result;
Expand Down

0 comments on commit 7a4fbef

Please sign in to comment.