Skip to content

Commit

Permalink
Fix Listing 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Diehl committed Sep 12, 2024
1 parent 118c3c7 commit 3df9567
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions _posts/2024-08-15-addendum.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ tags: Addendum

It does not matter how often one proofreads the book, there will be always bugs in the code or some issues. We will document the issues here and update the code on [GitHub](https://github.com/ModernCPPBook/Examples). Of course, we will update the potential new release of the book accordingly.

## Chapter 3

[Listing 3.3](https://github.com/ModernCPPBook/Examples/blob/main/notebooks/Chapter_3.ipynb) the cases for even and odd are wrong in the code and should be chnaged to

{% highlight c++ %}
if (values.size() % 2 == 0) {
median = *mid; |\label{container:median:list:defref}|
} else {
auto mid_one = values.begin();
std::advance(mid_one, mid_index + 1);
median = 0.5 * (*mid + *mid_one);
}
{% endhighlight %}

## Chapter 15

Expand Down

0 comments on commit 3df9567

Please sign in to comment.