diff --git a/1-ProceduralProgramming/2b-hands-on.ipynb b/1-ProceduralProgramming/2b-hands-on.ipynb index f1346a6bf24d0f8bae65eb9cf11e28f02dad759d..83fe58efee1472a1ff528d74c846a5ab9656a690 100644 --- a/1-ProceduralProgramming/2b-hands-on.ipynb +++ b/1-ProceduralProgramming/2b-hands-on.ipynb @@ -22,6 +22,11 @@ "Any real number can be approximated by the ratio between two integers. \n", "\n", "We will choose here to approximate any real `r` by an expression `numerator / 2^exponent`, where both `numerator` and `exponent` are integers.\n", + "$$\n", + "\\forall r \\, \\in \\mathbb{R}, \\quad r \\simeq \\frac{a}{2^b} \\quad \\text{with} \\quad [a, \\, b] \\in \\mathbb{Z}^2.\n", + "$$\n", + "\n", + "In practice, if we fix the value for the exponent $b$ we can compute the numerator $a$ through $a = r \\cdot 2^b$, which gives an approximation of $r$ as $r_{\\text{approx}} = a \\cdot 2^{-b}$.\n", "\n", "The higher the numerator and exponent values, the more accurate the approximation can be. For example, 0.65 can be approximated successively by: \n", "* 1 / 2<sup>1</sup> = 0.5 \n", diff --git a/1-ProceduralProgramming/3-Types.ipynb b/1-ProceduralProgramming/3-Types.ipynb index 53b9ce315748c904d4167ec01154f9a058cb4060..d831fec216d7ff61cfebaeba9ba442ba3478fdc3 100644 --- a/1-ProceduralProgramming/3-Types.ipynb +++ b/1-ProceduralProgramming/3-Types.ipynb @@ -1067,6 +1067,13 @@ "}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Fore more details about `auto`'s type deduction, you can check the C++ weekly videos at [this link](https://www.youtube.com/watch?v=tn69TCMdYbQ) and also [this one](https://www.youtube.com/watch?v=E5L66fkNlpE) regarding `decltype(auto)`'s usage. " + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/1-ProceduralProgramming/4-Functions.ipynb b/1-ProceduralProgramming/4-Functions.ipynb index ee305a27db85f04926dd7306f1a7e7851491bd56..3cd54af24d944efb2484a12b42458049b0ca2dc2 100644 --- a/1-ProceduralProgramming/4-Functions.ipynb +++ b/1-ProceduralProgramming/4-Functions.ipynb @@ -57,7 +57,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Due to the use of notebooks we won't need much proper function declaration, but we will revisit this [much later](../6-InRealEnvironment/2-FileStructure.ipynb) when we will see how a real project is written with different files involved." + "Due to the use of notebooks we will not need to separate clearly function declaration from its definition, but we will revisit this [much later](../6-InRealEnvironment/2-FileStructure.ipynb) when we will see how a real project is written with different files involved." ] }, { @@ -134,21 +134,21 @@ "- **parameter** is the name used when speaking about what is between the parenthesis during the function definition (`numerator` and `denominator` in the function definition)\n", "- **argument** is what is passed when the function is effectively called within your code (`num` and `denom` in the above cell)\n", "\n", - "I don't guarantee I am using the right term everywhere in the code: I'm not a purist and often use one for another (if you want to remember properly a helpful mnemotechnic is that **a**rguments are **a**ctual).\n" + "I do not guarantee that I am using the right term everywhere in the code: I'm not a purist and often use one for another (if you want to remember properly a helpful mnemotechnic is that **a**rguments are **a**ctual).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### Functions can't be nested, or declared within blocks" + "#### Functions cannot be nested, or declared within blocks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Functions can't be nested in C++, contrary to some other languages such as Python:" + "Functions cannot be nested in C++, contrary to some other langages such as Python:" ] }, { @@ -273,7 +273,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "As in C++ you can't return several values in the return type, passing by reference is a way to get in output several values (C++ 11 introduced in the standard library a workaround to get several values in return type with a so-called `std::tuple`, but the passing by reference remains the better way to do so in most cases)." + "As in C++ you cannot return several values in the return type, passing by reference is a way to get in output several values (C++ 11 introduced in the standard library a workaround to get several values in return type with a so-called `std::tuple`, but the passing by reference remains the better way to do so in most cases)." ] }, { @@ -355,7 +355,7 @@ "source": [ "The developer made two important mistakes:\n", "* The return value of `ComputeDivision` is not checked, so something is printed on screen.\n", - "* This is something completely out of control: quotient and remainder don't get a default value that would help to see if something is askew. The behaviour is undefined: you have no guarantee on the values the program will print (currently I see the same values as in the previous function call, but another compiler/architecture/etc... might yield another wrong value." + "* This is something completely out of control: quotient and remainder do not get a default value that would help to see if something is askew. The behaviour is undefined: you have no guarantee on the values the program will print (currently I see the same values as in the previous function call, but another compiler/architecture/etc... might yield another wrong value." ] }, { @@ -437,7 +437,7 @@ "source": [ "## Alternate function syntax\n", "\n", - "There is now since C++ 11 another way to declare a function; it is not widespread but is advised by some developers (see for instance [this blog post](https://blog.petrzemek.net/2017/01/17/pros-and-cons-of-alternative-function-syntax-in-cpp/) which lists pros and cons of both syntaxes).\n", + "There is now since C++ 11 another way to declare a function using so called `trailing return types`; it is not widespread but is advised by some developers (see for instance [this blog post](https://blog.petrzemek.net/2017/01/17/pros-and-cons-of-alternative-function-syntax-in-cpp/) which lists pros and cons of both syntaxes).\n", "\n" ] }, @@ -519,9 +519,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### **[WARNING]** Return type doesn't count!\n", + "### **[WARNING]** Return type does not count!\n", "\n", - "It's not the entire signature of the function that is taken into account when possible ambiguity is sought by the compiler: the return type isn't taken into account. So the following cases won't be accepted:" + "It is not the entire signature of the function that is taken into account when possible ambiguity is sought by the compiler: the return type is not taken into account. So the following cases will not be valid:" ] }, { @@ -546,14 +546,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### **[WARNING]** This is a C++ only feature and won't work in C!" + "### **[WARNING]** This is a C++ only feature and will not work in C!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "In C you can't do that: if you run a simple program with overload:\n", + "In C you cannot do the following: if you run a simple program with overload:\n", "\n", "```c\n", "#include <stdio.h>\n", @@ -598,7 +598,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Good practice: don't make signature vary only by a reference or a pointer" + "### Good practice: do not make signature vary only by a reference or a pointer" ] }, { @@ -1497,13 +1497,13 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xcpp17" + "name": "xeus-cling-cpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", - "name": "c++", + "name": "C++17", "version": "17" }, "latex_envs": { diff --git a/1-ProceduralProgramming/4b-hands-on.ipynb b/1-ProceduralProgramming/4b-hands-on.ipynb index 66df5ca2dfbcbd16dd1b8ef05adbfbc55733b38d..09375d4609573349e5a722790bd0f0461eb932a2 100644 --- a/1-ProceduralProgramming/4b-hands-on.ipynb +++ b/1-ProceduralProgramming/4b-hands-on.ipynb @@ -44,7 +44,7 @@ "0.65 ~ 21 / 2^5 \n", "0.65 ~ 42 / 2^6 \n", "0.65 ~ 83 / 2^7 \n", - "0.65 ~ 166 / 2^8. \n", + "0.65 ~ 166 / 2^8\n", "\n", "0.35 ~ 1 / 2^1 \n", "0.35 ~ 1 / 2^2 \n", @@ -127,13 +127,23 @@ "Expected result is something like:\n", "\n", "```\n", - "[With numerator < 15]: 0.65 ~ 0.625 (10/2^4)\n", - "[With numerator < 255]: 0.65 ~ 0.648438 (166/2^8)\n", - "[With numerator < 15]: 0.35 ~ 0.34375 (11/2^5)\n", - "[With numerator < 255]: 0.35 ~ 0.349609 (179/2^9)\n", + "[With numerator < 15]: 0.65 ~ 0.625 (10 / 2^4)\n", + "[With numerator < 255]: 0.65 ~ 0.648438 (166 / 2^8)\n", + "[With numerator < 15]: 0.35 ~ 0.34375 (11 / 2^5)\n", + "[With numerator < 255]: 0.35 ~ 0.349609 (179 / 2^9)\n", "```" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -209,15 +219,15 @@ "*Expected result*:\n", "\n", "```\n", - "[With 2 bits]: 0.65 ~ 0.75 (3/2^2)\n", - "[With 4 bits]: 0.65 ~ 0.625 (10/2^4)\n", - "[With 6 bits]: 0.65 ~ 0.65625 (42/2^6)\n", - "[With 8 bits]: 0.65 ~ 0.648438 (166/2^8)\n", - "\n", - "[With 2 bits]: 0.35 ~ 0.375 (3/2^3)\n", - "[With 4 bits]: 0.35 ~ 0.34375 (11/2^5)\n", - "[With 6 bits]: 0.35 ~ 0.351562 (45/2^7)\n", - "[With 8 bits]: 0.35 ~ 0.349609 (179/2^9)\n", + "[With 2 bits]: 0.65 ~ 0.75 (3 / 2^2)\n", + "[With 4 bits]: 0.65 ~ 0.625 (10 / 2^4)\n", + "[With 6 bits]: 0.65 ~ 0.65625 (42 / 2^6)\n", + "[With 8 bits]: 0.65 ~ 0.648438 (166 / 2^8)\n", + "\n", + "[With 2 bits]: 0.35 ~ 0.375 (3 / 2^3)\n", + "[With 4 bits]: 0.35 ~ 0.34375 (11 / 2^5)\n", + "[With 6 bits]: 0.35 ~ 0.351562 (45 / 2^7)\n", + "[With 8 bits]: 0.35 ~ 0.349609 (179 / 2^9)\n", "```" ] }, @@ -265,15 +275,15 @@ "*Expected result*:\n", "\n", "```\n", - "[With 2 bits]: 0.65 ~ 0.75 (3/2^2) [error = 15/100]\n", - "[With 4 bits]: 0.65 ~ 0.625 (10/2^4) [error = 4/100]\n", - "[With 6 bits]: 0.65 ~ 0.65625 (42/2^6) [error = 1/100]\n", - "[With 8 bits]: 0.65 ~ 0.648438 (166/2^8) [error = 0/100]\n", - "\n", - "[With 2 bits]: 0.35 ~ 0.375 (3/2^3) [error = 7/100]\n", - "[With 4 bits]: 0.35 ~ 0.34375 (11/2^5) [error = 2/100]\n", - "[With 6 bits]: 0.35 ~ 0.351562 (45/2^7) [error = 0/100]\n", - "[With 8 bits]: 0.35 ~ 0.349609 (179/2^9) [error = 0/100]\n", + "[With 2 bits]: 0.65 ~ 0.75 (3 / 2^2) [error = 15/100]\n", + "[With 4 bits]: 0.65 ~ 0.625 (10 / 2^4) [error = 4/100]\n", + "[With 6 bits]: 0.65 ~ 0.65625 (42 / 2^6) [error = 1/100]\n", + "[With 8 bits]: 0.65 ~ 0.648438 (166 / 2^8) [error = 0/100]\n", + "\n", + "[With 2 bits]: 0.35 ~ 0.375 (3 / 2^3) [error = 7/100]\n", + "[With 4 bits]: 0.35 ~ 0.34375 (11 / 2^5) [error = 2/100]\n", + "[With 6 bits]: 0.35 ~ 0.351562 (45 / 2^7) [error = 0/100]\n", + "[With 8 bits]: 0.35 ~ 0.349609 (179 / 2^9) [error = 0/100]\n", "```" ] }, diff --git a/1-ProceduralProgramming/6b-hands-on.ipynb b/1-ProceduralProgramming/6b-hands-on.ipynb index c736f26d63a5b63b69d7a28908e4019d7bab0844..d920232c6b3dfb479ce585526e9d0c7f6a362b81 100644 --- a/1-ProceduralProgramming/6b-hands-on.ipynb +++ b/1-ProceduralProgramming/6b-hands-on.ipynb @@ -13,7 +13,7 @@ "source": [ "### __EXERCISE 8: Multiplication by an integer__\n", "\n", - "Write the `Multiply()` function that computes the approximate product of a real by an integer coefficient and returns an integer. \n", + "Write the `Multiply()` function that calculates the product of an approximated real by an integer coefficient and returns an integer. \n", "\n", "*Reminder*: a real is approximated by `numerator / 2^exponent`; your function should rely upon `ComputePowerOf2Approx()` and `TimesPowerOf2()` functions.\n", "\n", @@ -87,7 +87,12 @@ "source": [ "### __EXERCISE 9: display sum of two Multiply__\n", "\n", - "Write a `DisplaySumOfMultiply` function which will write the computation of the sum of two real numbers through their approximation (see expected result below)\n", + "Write a `DisplaySumOfMultiply` function which will write the computation of the sum of two approximated real numbers that have each been multiplied by a different integer coefficient.\n", + "\n", + "The function is expected to compute and display the following:\n", + "$$\n", + "\\displaystyle r_1 \\cdot c_1 + r_2 \\cdot c_2 \\simeq (a_1 \\cdot 2^{-b_1}) \\cdot c_1 + (a_2 \\cdot 2^{-b_2}) \\cdot c_2\n", + "$$\n", "\n", "This function will take 5 arguments:\n", "\n", diff --git a/2-ObjectProgramming/3b-hands-on.ipynb b/2-ObjectProgramming/3b-hands-on.ipynb index 8488d2de11d963ba99d9724771544c85f67c5640..54f4d10ff5081fb37fb77a327dd440824ca7bf43 100644 --- a/2-ObjectProgramming/3b-hands-on.ipynb +++ b/2-ObjectProgramming/3b-hands-on.ipynb @@ -13,7 +13,7 @@ "source": [ "### **EXERCISE 15: change interface of `PowerOfTwoApprox` struct**\n", "\n", - "* Transform `Compute()` into a constructor. This constructor can't any longer return a double value; introduce a method `AsDouble()` which returns the approximation (that by definition may be computed from data attributes `numerator_` and `exponent_`).\n", + "* Transform `Compute()` into a constructor. As a constructor cannot return a value, introduce a method `AsDouble()` which returns the approximation (that by definition may be computed from data attributes `numerator_` and `exponent_`).\n", "* Assign a default value of `0` to data attributes (if not already done previously!)\n", "\n", "Expected output is the same as previously.\n", diff --git a/2-ObjectProgramming/4b-hands-on.ipynb b/2-ObjectProgramming/4b-hands-on.ipynb index 08a3d701385367f55348d7a0333327a712a533d3..3143cec74aa987c05c702b96569b132fbb9666a2 100644 --- a/2-ObjectProgramming/4b-hands-on.ipynb +++ b/2-ObjectProgramming/4b-hands-on.ipynb @@ -65,7 +65,7 @@ "\n", "Use two methods in this class:\n", "\n", - "* A public method `Do()` which in its implementation will call the test for 0.65 and 0.35. this method will take the number of bits as argument.\n", + "* A public method `Do()` which in its implementation will call the test for 0.65 and 0.35. This method will take the number of bits as argument.\n", "* A private method `Display()` which will provide the display for a given double value (and will therefore be called twice in `Do()`: once for 0.65 and once for 0.35).\n", "\n", "New main should look like:" diff --git a/2-ObjectProgramming/7-polymorphism.ipynb b/2-ObjectProgramming/7-polymorphism.ipynb index fc8f936d95dce856d8cff46da177d3cbdcfbf65f..00f0726390392680588ada595308f1e101c51d35 100644 --- a/2-ObjectProgramming/7-polymorphism.ipynb +++ b/2-ObjectProgramming/7-polymorphism.ipynb @@ -934,7 +934,7 @@ "source": [ "So you could devise a way to identify which is the dynamic type of your `PolymorphicVehicle` pointer and cast it dynamically to the rightful type so that extended API offered by the derived class is accessible.\n", "\n", - "If you find this clunky, you are not alone: by experience if you really need to resort to **dynamic_cast** it's probably your data architecture needs some revision. But maybe the mileage vary for other developers, and it's useful to know the possibility exists." + "If you find this clunky, you are not alone: by experience if you really need to resort to **dynamic_cast** it's probably that your data architecture needs some revision. But maybe the mileage vary for other developers, and it's useful to know the possibility exists." ] }, { @@ -1029,7 +1029,7 @@ "source": [ "## Virtual destructor to avoid partial destruction\n", "\n", - "I indicated earlier that destructors might be virtual, but in fact I should have said than for most of the non final classes the destructor should be virtual:" + "I indicated earlier that destructors might be virtual, but in fact I should have said that for most of the non final classes the destructor should be virtual:" ] }, { diff --git a/2-ObjectProgramming/7b-hands-on.ipynb b/2-ObjectProgramming/7b-hands-on.ipynb index f64eff5581372498fedef0c42ea113a0269d61d0..b833f6705ac8682a756db45a402df31cd28255c4 100644 --- a/2-ObjectProgramming/7b-hands-on.ipynb +++ b/2-ObjectProgramming/7b-hands-on.ipynb @@ -46,7 +46,7 @@ "\n", "Of course, we still abide by the DRY principle and we want to specialize only the code related to `Do()` method. \n", "\n", - "**Note:** The design proposed here is clearly not the best - it's just a pretense to use practise virtual methods and encapsulation.\n", + "**Note:** The design proposed here is clearly not the best - it is just a pretense to practise virtual methods and encapsulation.\n", "\n", "The `main()` to use:" ] diff --git a/3-Operators/3b-hands-on.ipynb b/3-Operators/3b-hands-on.ipynb index db316527cce414900c19777630be100da9312a4a..f1858dd3f25fc9b5c626595118780c0413cbf916 100644 --- a/3-Operators/3b-hands-on.ipynb +++ b/3-Operators/3b-hands-on.ipynb @@ -13,7 +13,7 @@ "source": [ "### **EXERCISE 29: `operator<<`**\n", "\n", - "Introduce an `operator<<` for class `PowerOfTwoApprox` which provides the numerator and exponent used, e.g. `10/2^4`.\n", + "Introduce an `operator<<` for class `PowerOfTwoApprox` which provides the numerator and exponent used, e.g. `10 / 2^4`.\n", "\n", "Use it in `TestDisplayPowerOfTwoApprox::Display()`.\n", "\n", diff --git a/3-Operators/4-CanonicalForm.ipynb b/3-Operators/4-CanonicalForm.ipynb index 260ddf7e4891f16e52ca553f12e41af27a3a3b13..5e150b8dc248fad509611e6f31d6f8ea5b54e8f9 100644 --- a/3-Operators/4-CanonicalForm.ipynb +++ b/3-Operators/4-CanonicalForm.ipynb @@ -436,7 +436,7 @@ "\n", "Copy construction may in fact be quite dangerous:\n", "\n", - "* As we've just seen, assignment and construction may differ in implementation, which is not a good thing. There are ways to define one in function of the other (see for instance item 11 of [Effective C++](../bibliography.ipynb#Effective-C++-/-More-Effective-C++) but they aren't that trivial.\n", + "* As we've just seen, assignment and construction may differ in implementation, which is not a good thing. There are ways to define one in function of the other (see for instance item 11 of [Effective C++](../bibliography.ipynb#Effective-C++-/-More-Effective-C++)) but they aren't that trivial.\n", "* Depending on somewhat complicated rules that have evolved with standard versions, some might or might not be defined implicitly.\n", "* More importantly, assignment operators may be a nightmare to maintain. Imagine you have a class for which you overload manually the assignment operator and/or the copy constructor. If later you add a new data attribute, you have to make sure not to forget to add it in both implementations; if you forget once you will enter the realm of undefined behaviour... and good luck for you to find the origin of the bug!\n", "\n", diff --git a/4-Templates/1-Intro.ipynb b/4-Templates/1-Intro.ipynb index 88ea95d7da64c76a698c551cebd16479e8a4e685..8218cad7debbbc53b3bef99c199f217da0553e88 100644 --- a/4-Templates/1-Intro.ipynb +++ b/4-Templates/1-Intro.ipynb @@ -655,7 +655,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are exactly zero differences between both keywords; some authors suggest conventions (e.g. use `typename` for POD types and `class` for the more complicated types) but they are just that: conventions!\n", + "Since C++ 17, there are exactly zero differences between both keywords (before C++ 17, they were almost everywhere equivalent except in a very specific case - called template template parameter that we'll see shortly - in which typename did not work. You can check [this link](https://stackoverflow.com/questions/2023977/what-is-the-difference-between-typename-and-class-template-parameters) if you want to know more); some authors suggest conventions (e.g. use `typename` for POD types and `class` for the more complicated types) but they are just that: conventions!\n", "\n", "* The definition of the templates must be provided in header files, not in compiled files. The reason is that the compiler can't know all the types for which the template might be used: you may use `std::min` for your own defined types (provided they define a `<` operator...) and obviously STL writers can't foresee which type you will come up with!\n", "* The compiler will generate the code for each type given to the template; for instance if `Convert<double>`, `Convert<unsigned int>` and `Convert<short>` are used in your code, the content of this template function will be instantiated thrice! This can lead to **code bloat**: lots of assembler code is generated, and compilation time may increase significatively. \n", diff --git a/4-Templates/5-MoreAdvanced.ipynb b/4-Templates/5-MoreAdvanced.ipynb index 1dfaf80d47c5c44fd4d53d7efb38a441e99ae4f9..f43a7b2a2ab04fe612ed517b22f9a2dda2670ced 100644 --- a/4-Templates/5-MoreAdvanced.ipynb +++ b/4-Templates/5-MoreAdvanced.ipynb @@ -609,7 +609,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In practice you shouldn't need to use that too often, but as the topics in this notebook it is worthy to know the possibility exists (that may help you understand an error message should you use a library using them). I had to resort to them a couple of times, especially along policies.\n", + "In practice you shouldn't need to use that too often, but in the context of this notebook it is worth knowing that the possibility exists (it may help you understand an error message should you use a library using them). I had to resort to them a couple of times, especially along policies.\n", "\n", "If you want to learn more about them, you should really read [Modern C++ design](../bibliography.ipynb#Modern-C++-Design).\n", "\n", diff --git a/5-UsefulConceptsAndSTL/2-RAII.ipynb b/5-UsefulConceptsAndSTL/2-RAII.ipynb index d148b5017245556798e61106104a01d02be62c91..1291659ac7839f6ac9e673f28fb019010d861c52 100644 --- a/5-UsefulConceptsAndSTL/2-RAII.ipynb +++ b/5-UsefulConceptsAndSTL/2-RAII.ipynb @@ -15,7 +15,7 @@ "\n", "This chapter is one of the most important in this tutorial: it is an idiom without which the most common critic against C++ is totally justified!\n", "\n", - "Often, people who criticizes the language say C++ is really tricky and that is extremely easy to leak memory all over the way, and that it sorely miss a [**garbage collector**](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) which does the job of cleaning-up and freeing the memory when the data are no longer used.\n", + "Often, people who criticizes the language say C++ is really tricky and that is extremely easy to leak memory all over the place, and that it sorely misses a [**garbage collector**](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) which does the job of cleaning-up and freeing the memory when the data are no longer used.\n", "\n", "However, garbage collection, used for instance in Python and Java, is not without issues itself: the memory is not always freed as swiftly as possible, and the bookkeeping of references is not free performance-wise.\n", "\n", diff --git a/5-UsefulConceptsAndSTL/3-Containers.ipynb b/5-UsefulConceptsAndSTL/3-Containers.ipynb index 506e3a710fe9e50dfcabc4e5ca6370532dd71f58..1169550f06aa9aba4e7f54aef3962a6988e51cc4 100644 --- a/5-UsefulConceptsAndSTL/3-Containers.ipynb +++ b/5-UsefulConceptsAndSTL/3-Containers.ipynb @@ -668,7 +668,7 @@ "\n", "## Incrementing / decrementing iterators\n", "\n", - "As you POD types, there are both a pre- and post-increment available:\n" + "As with POD types, there are both a pre- and post-increment available:\n" ] }, { diff --git a/5-UsefulConceptsAndSTL/4-AssociativeContainers.ipynb b/5-UsefulConceptsAndSTL/4-AssociativeContainers.ipynb index 61e9f42939ca1f88152d123dd158f6e1a363370e..45dbafdaa6b2965d1eee8c625f112b61249c9f49 100644 --- a/5-UsefulConceptsAndSTL/4-AssociativeContainers.ipynb +++ b/5-UsefulConceptsAndSTL/4-AssociativeContainers.ipynb @@ -310,7 +310,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "So if you provide a wrong key, it doesn't yell and create instead on the spot a new entry, filling the associated value with the default constructor for the type...\n", + "So if you provide a wrong key, it doesn't yell and instead creates a new entry on the spot, filling the associated value with the default constructor for the type...\n", "\n", "To do it properly (but more verbose!), use the `find()` method (if you're intrigued by the use of iterator there, we will present them more in details in the notebook about [algorithms](./7-Algorithms.ipynb)):" ] @@ -403,13 +403,13 @@ "* Adding new elements is more expensive.\n", "* The result is not ordered, and there are no rules whatsoever: two runs on the same computer might not yield the list in the same order.\n", "\n", - "The constraint of the key is different too: the key must be **hashable**: there must be a specialization of `std::hash` for the type used for key. It must also define `operator==`.\n", + "The constraint on the key is different too: the key must be **hashable**, meaning that there must be a specialization of `std::hash` for the type used for key. It must also define `operator==`.\n", "\n", "STL provides good such **hash tables** for POD types (and few others like `std::string`); it is not trivial (but still possible - see for instance [The C++ Standard Library: A Tutorial and Reference](../bibliography.ipynb#The-C++-Standard-Library:-A-Tutorial-and-Reference) for a discussion on this topic) to add new ones.\n", "\n", "So to put in a nutshell, if your key type is already handled by the STL and you spend more time reading data than inserting new ones, you should really use this type. \n", "\n", - "Just an additional note: [The C++ Standard Library: A Tutorial and Reference](../bibliography.ipynb#The-C++-Standard-Library:-A-Tutorial-and-Reference) recommends changing the default internal setting of the class for efficiency: there is an internal float value named `max_load_factor` which default value is 1; API of the class introduce a mutator to modify it. He says 0.7f or 0.8f is more efficient; I haven't benchmarked and trusted him on this and am using it in my library.\n" + "Just an additional note: [The C++ Standard Library: A Tutorial and Reference](../bibliography.ipynb#The-C++-Standard-Library:-A-Tutorial-and-Reference) recommends changing the default internal setting of the class for efficiency: there is an internal float value named `max_load_factor` which has a default value of 1; API of the class introduces a mutator to modify it. He says 0.7f or 0.8f is more efficient; I haven't benchmarked and trusted him on this and am using it in my library.\n" ] }, { diff --git a/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb b/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb index 5a4ffee30f3255939e74e7ca29e4e99f175b2f61..f09db6e3ffc314b3a1b0bde1c8c1d63f8e8781b0 100644 --- a/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb +++ b/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb @@ -901,7 +901,7 @@ "source": [ "## Forwarding reference (or universal reference)\n", "\n", - "Just a quick warning (you should really read [Effective modern C++](../bibliography.ipynb#Effective-Modern-C++) for an extensive discussion on the topic; blog [FluentCpp](https://www.fluentcpp.com/2018/02/06/understanding-lvalues-rvalues-and-their-references) provides some intel about it... and tells you as well to ready Scott Meyer's book to learn more!): seeing `&&` doesn't automatically mean it is a r-value reference.\n", + "Just a quick warning (you should really read [Effective modern C++](../bibliography.ipynb#Effective-Modern-C++) for an extensive discussion on the topic; blog [FluentCpp](https://www.fluentcpp.com/2018/02/06/understanding-lvalues-rvalues-and-their-references) provides some intel about it... and tells you as well to read Scott Meyer's book to learn more!): seeing `&&` doesn't automatically mean it is a r-value reference.\n", "\n", "There is a very specific case when:\n", "- The argument is template \n", diff --git a/6-InRealEnvironment/1-SetUpEnvironment.ipynb b/6-InRealEnvironment/1-SetUpEnvironment.ipynb index 2cabdb5a2e74cc8a77365f76e9bcebe7b6a0c588..88f8052b134655a6020cbee4c35fc4d01ec80fe8 100644 --- a/6-InRealEnvironment/1-SetUpEnvironment.ipynb +++ b/6-InRealEnvironment/1-SetUpEnvironment.ipynb @@ -238,7 +238,7 @@ "_Vim_ and _emacs_ are often either already installed or available easily with a distribution package (_apt_, _dnf_, etc...); for IDEs here are few of them:\n", "\n", "* [Visual Studio Code](https://code.visualstudio.com/), which gained traction in last few years and is one of the most sizeable GitHub project. This is an open-source and multi-platform editor maintained by Microsoft, not to be confused with [Visual Studio](https://visualstudio.microsoft.com/?rr=https%3A%2F%2Fwww.google.com%2F) - also provided by Microsoft on Windows (and with a fee).\n", - "* [CLion](https://www.jetbrains.com/clion/) by JetBrains is also a rising star in IDEs; a free version is available for students (you may now PyCharm by the same company)\n", + "* [CLion](https://www.jetbrains.com/clion/) by JetBrains is also a rising star in IDEs; a free version is available for students (you may know PyCharm by the same company)\n", "* [Eclipse CDT](https://www.eclipse.org/cdt/) and [NetBeans](https://netbeans.org/) are other IDEs with more mileage.\n", "* [QtCreator](https://www.qt.io/qt-features-libraries-apis-tools-and-ide) is not just for Qt edition and might be used as a C++ IDE as well.\n", "* [XCode](https://developer.apple.com/xcode) is the editor provided by Apple on macOS.\n", diff --git a/6-InRealEnvironment/3-Compilers.ipynb b/6-InRealEnvironment/3-Compilers.ipynb index 570bd4c5823b564eecc4fe5c53d8ba08510eeb9e..7e7639ee76a200c63b19d8ea8b8f347fc39c3f51 100644 --- a/6-InRealEnvironment/3-Compilers.ipynb +++ b/6-InRealEnvironment/3-Compilers.ipynb @@ -17,7 +17,7 @@ "\n", "I recommend using them both (and more if you can!): each compiler gets its own spin on the standard, and sometimes a perfectly valid code will be refused by one... whereas (more often) invalid code will unduly get a free pass with one of the compilers.\n", "\n", - "So the more compiler with which you may test your code, the merrier!\n", + "So the more compilers with which you may test your code, the merrier!\n", "\n", "If you're Inria staff, Inria also provides a licence to [Intel compiler](https://software.intel.com/en-us/c-compilers).\n", "\n", diff --git a/6-InRealEnvironment/4-ThirdParty.ipynb b/6-InRealEnvironment/4-ThirdParty.ipynb index d47abf16f01487437cda6cc264ffa379ab19922f..5ce1937f76b8bd939975a7ec59dc2d6ddacfe8f8 100644 --- a/6-InRealEnvironment/4-ThirdParty.ipynb +++ b/6-InRealEnvironment/4-ThirdParty.ipynb @@ -147,7 +147,7 @@ "\n", "The few drawbacks I can see are: \n", "\n", - "* You have to figure out how your build system take this into account.\n", + "* You have to figure out how your build system takes this into account.\n", "* You have to make sure it is portable: another user may not place these third-party headers in the same location as you, and you have to figure out a proper way to indicate where they are. This is by no mean overwhelming, but still requires a bit of work. This is especially so if the third party library is directly embedded in your code (might happen, especially if the library is header only).\n" ] }, diff --git a/6-InRealEnvironment/5-Namespace.ipynb b/6-InRealEnvironment/5-Namespace.ipynb index b445b7035d081e59cdbe86cd93e86866dc067541..332c5ef3536ddccf25ae45085d765605110ebe67 100644 --- a/6-InRealEnvironment/5-Namespace.ipynb +++ b/6-InRealEnvironment/5-Namespace.ipynb @@ -17,7 +17,7 @@ "\n", "Even worse, if you use two libraries that both provide for instance their own spin over `Vector`, you are stuck as there will be ambiguity if these two classes are to be used in the same file.\n", "\n", - "Strangely enough, with C for which the issue may arise as well no solution was provided to eschew this potential name clashing.\n", + "Strangely enough, with C for which the issue may arise as well, no solution was provided to eschew this potential name clashing.\n", "\n", "Fortunately, C++ introduced the **namespaces** for this: a **namespace** is an entity which groups together classes, functions and so on... So far, as we didn't define explicitly one we were actually in the **global namespace**.\n", "\n", diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise10.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise10.cpp index 1fdf3f2426c92f9ff6e3d76255dc833e0480cee3..b845726b18c536ad2d6152559111375c3aa47718 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise10.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise10.cpp @@ -119,6 +119,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise11.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise11.cpp index 9c82b49745fe85ed3cc45cfb20864a95d5fa1d25..adc58e71f948dfd069f29ee2bbfa4768eda95882 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise11.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise11.cpp @@ -120,6 +120,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise12.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise12.cpp index 685261de4776408d3698eb639d6892ea8010ede2..1329bb21bb09d24db08c1c80cdb0f543cf9e3a88 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise12.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise12.cpp @@ -132,6 +132,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise4.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise4.cpp index 3e8f065d411b6f3d57401276816405117defc65c..5ac11d9021ccbee45502de9a3a4a64fc7ab3f502 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise4.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise4.cpp @@ -83,7 +83,8 @@ void DisplayPowerOf2Approx(int max_numerator, double value) HelperDisplayPowerOf2Approx(value, ++exponent, numerator, denominator); } while (numerator < max_numerator); - + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperDisplayPowerOf2Approx(value, --exponent, numerator, denominator); double double_quotient = static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise5.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise5.cpp index 3b573caa93d64e43c031cbcf1a0be421fb67d76b..3e49bd3732ad48bc0877b12aeef72bf1b17eec44 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise5.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise5.cpp @@ -87,7 +87,8 @@ void DisplayPowerOf2Approx(int Nbits, double value) HelperDisplayPowerOf2Approx(value, ++exponent, numerator, denominator); } while (numerator < max_numerator); - + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperDisplayPowerOf2Approx(value, --exponent, numerator, denominator); double double_quotient = static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise6.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise6.cpp index 3e6147d8f094ddc247c4764f08082f722f76024a..02e082797067d0a65c964fee539df4ad50422ce5 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise6.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise6.cpp @@ -111,6 +111,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise7.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise7.cpp index 169669607e347a217357820661f4ca383275ef28..3b431468763a4cf8404713ddf2888376ca50b362 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise7.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise7.cpp @@ -113,6 +113,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise8.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise8.cpp index a35c205a14584fd0529d4ceb5960f8569adf367d..49ede58bfa903d2a08a550d040590dada5e48517 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise8.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise8.cpp @@ -116,6 +116,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercise9.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercise9.cpp index ba369f4c2389dd9bb33fb2aab64fa8d1b4fa8c57..850529b719909e3b4ff413599559bf29ce668eb1 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercise9.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercise9.cpp @@ -119,6 +119,8 @@ double ComputePowerOf2Approx(int Nbits, double value, int& numerator, int& expon } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp index 8020810c27e96556e43a267aad4e18f1e50e9e48..53bb7ed0608aa58a8079c615a32cbbab64a55218 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp @@ -130,6 +130,8 @@ double ComputePowerOf2Approx(int Nbits, double value, PowerOfTwoApprox& approxim } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise14.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise14.cpp index b1b80f8a4f4c432bada7200a5a74b621e2ddc345..328bd76ee12cb92ac5db672c1b95de5fcd22aca9 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise14.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise14.cpp @@ -130,6 +130,8 @@ double PowerOfTwoApprox::Compute(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); return static_cast<double>(numerator) / denominator; diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise15.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise15.cpp index 1cf41c7931ecc379192ed4eb3e3b41a4cd9f6fc8..5b701967e9a7f1683541625c517ea4230642f416 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise15.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise15.cpp @@ -135,6 +135,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise16.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise16.cpp index 000b2f6f6f6e7bab5c392474f2b94db961a90017..72ecd5d7395b38fdd017d6769a3ceed5d564b85b 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise16.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise16.cpp @@ -144,6 +144,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise17.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise17.cpp index 7d2f1a91de3983552e753a22ce59dbf28837392d..0c0311d7970d554b70c05bff9316fa2e5cf2e975 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise17.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise17.cpp @@ -150,6 +150,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise18.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise18.cpp index b506d3a1beabe1b173825deb8cdb85f4b9948957..4f2d5d8d7d457f3f47092d74a313507c3974cebc 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise18.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise18.cpp @@ -171,6 +171,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise19.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise19.cpp index e94bd2af90e6fc0ccbdb6526c191da84a82b6076..f101324e442f8179795cef3803255e285a0a28aa 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise19.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise19.cpp @@ -186,6 +186,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise20.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise20.cpp index 6101786723bf2aa1659ed4bd5f01919daaa3c844..20791365e7fabd832d772e638d69f2d6de56eccb 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise20.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise20.cpp @@ -206,6 +206,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise21.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise21.cpp index b68d9c96ee4b02fc59d26bdc0f9f91dbed2ade2d..79bb8809451f1f7865fe97fdb24609e94bf470ef 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise21.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise21.cpp @@ -258,6 +258,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise22.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise22.cpp index 89e1bec19a53fc1fcfc4c3116e1615d6673ca250..af3414de215aaa6908fbee3fcbe96ee37f308394 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise22.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise22.cpp @@ -290,6 +290,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise23.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise23.cpp index 52ddba9e77ecb7d65e5f400ebde8404c37751d27..3e01dbf05f945562032f41f30f594701ed73f631 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise23.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise23.cpp @@ -321,6 +321,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise24.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise24.cpp index 7c870618f991a985a85fd927c91407f141994d2b..4549a5c43a5c1e4a07e2322340cdcaa7731280d5 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise24.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise24.cpp @@ -329,6 +329,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise25.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise25.cpp index 49109abb1efa2a7d3cf41351b21f0cd0903ccbda..2842107d198e62dbec8f4eacc868720ad4de73ab 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise25.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise25.cpp @@ -333,6 +333,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/3-Operators/Solution/exercise26.cpp b/HandsOn/3-Operators/Solution/exercise26.cpp index cc28d87e9a370a7ff75d067cde316c23fd0fb4c6..4e02824e4b1b36fd189ad5071e74dd07fac95197 100644 --- a/HandsOn/3-Operators/Solution/exercise26.cpp +++ b/HandsOn/3-Operators/Solution/exercise26.cpp @@ -333,6 +333,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/3-Operators/Solution/exercise27.cpp b/HandsOn/3-Operators/Solution/exercise27.cpp index 17a84f255feb5f835bf8d79d9a941e345fa0c207..21d37411d99eb0d8a67e87625353014b21017649 100644 --- a/HandsOn/3-Operators/Solution/exercise27.cpp +++ b/HandsOn/3-Operators/Solution/exercise27.cpp @@ -336,6 +336,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/3-Operators/Solution/exercise28.cpp b/HandsOn/3-Operators/Solution/exercise28.cpp index 05d9fa03475f843a6e26a540f7fe63f08a38bf9a..2cda11033dfa0b7ff5ea8c0bc1dd45a1552883c4 100644 --- a/HandsOn/3-Operators/Solution/exercise28.cpp +++ b/HandsOn/3-Operators/Solution/exercise28.cpp @@ -336,6 +336,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/3-Operators/Solution/exercise29.cpp b/HandsOn/3-Operators/Solution/exercise29.cpp index 5b1f6193158c49c3772a44ecba35596454fa8123..7a33a34e40140d1e3721abba45fd9ac97e62a31c 100644 --- a/HandsOn/3-Operators/Solution/exercise29.cpp +++ b/HandsOn/3-Operators/Solution/exercise29.cpp @@ -337,6 +337,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/3-Operators/Solution/exercise30.cpp b/HandsOn/3-Operators/Solution/exercise30.cpp index 98db739ce4b504ef7849f8333e6d2d6843e34381..2c2d0f48f1eac197e16cda282020bdd6c38373f7 100644 --- a/HandsOn/3-Operators/Solution/exercise30.cpp +++ b/HandsOn/3-Operators/Solution/exercise30.cpp @@ -337,6 +337,8 @@ PowerOfTwoApprox::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/4-Templates/Solution/exercise31.cpp b/HandsOn/4-Templates/Solution/exercise31.cpp index 7ca1e7bb4104f64f8097e2aaf78c1d1b1da8eeba..74e1d66c317dc3597add8bc0e77431c777ccc181 100644 --- a/HandsOn/4-Templates/Solution/exercise31.cpp +++ b/HandsOn/4-Templates/Solution/exercise31.cpp @@ -344,6 +344,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/4-Templates/Solution/exercise32.cpp b/HandsOn/4-Templates/Solution/exercise32.cpp index 1d868403924c3e9865b98510900138d7a341401e..432ffe2f00a02669fcb14cb7a2be32379b650e29 100644 --- a/HandsOn/4-Templates/Solution/exercise32.cpp +++ b/HandsOn/4-Templates/Solution/exercise32.cpp @@ -354,6 +354,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/4-Templates/Solution/exercise33.cpp b/HandsOn/4-Templates/Solution/exercise33.cpp index 8d08160daf166858b20284a00fc8ed5ebf9d465f..6137897a5bf182f09b8a336c7b5c7eb05324d96c 100644 --- a/HandsOn/4-Templates/Solution/exercise33.cpp +++ b/HandsOn/4-Templates/Solution/exercise33.cpp @@ -370,6 +370,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/4-Templates/Solution/exercise34.cpp b/HandsOn/4-Templates/Solution/exercise34.cpp index 7664082b276bffad88c973d11fdc9e800b8a2772..5c0cb248eafdacbfcce189451daba8e11431ffa8 100644 --- a/HandsOn/4-Templates/Solution/exercise34.cpp +++ b/HandsOn/4-Templates/Solution/exercise34.cpp @@ -376,6 +376,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/4-Templates/Solution/exercise35.cpp b/HandsOn/4-Templates/Solution/exercise35.cpp index c58565d035a9f2e39665b6eb9d3e1475406b6ee3..a572607fdb69392f474bd95905cd7dbf81794118 100644 --- a/HandsOn/4-Templates/Solution/exercise35.cpp +++ b/HandsOn/4-Templates/Solution/exercise35.cpp @@ -371,6 +371,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise36.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise36.cpp index b6f0201960afbe5202441330e062e101411f2e3c..53c786ea7515e94f2c4b5bc56ffd990a18a3adc4 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise36.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise36.cpp @@ -387,6 +387,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise37.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise37.cpp index 3a893dbf34452d05420fc2fe61c30de9e525db9d..50ff99d5c91f835cdba3aa245316ddd366f557ea 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise37.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise37.cpp @@ -403,6 +403,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise38.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise38.cpp index 7af8912f07bd5296fdb0b20a1b2bd74ca447f1a8..af494213c408040622c77ef77b0f24e8a57f95fd 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise38.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise38.cpp @@ -413,6 +413,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise39.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise39.cpp index 4daf58fc5da176d03341a8ea9c398bc273d103c2..f489e548f3e02cd7bdef3437b5f68ce4135e1f8f 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise39.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise39.cpp @@ -409,6 +409,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise40.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise40.cpp index 1c0f1c31615877112b31c3c842098c43018bd7f0..545d78c048d8ebe5df6413da40bb0df8ab28bc17 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise40.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise40.cpp @@ -410,6 +410,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise41.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise41.cpp index 14f437bf96bd96497cae05e8717c19e5a8ea9e47..35455be4a8d3f012142139c9a37a317011345dcc 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise41.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise41.cpp @@ -410,6 +410,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise42.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise42.cpp index 364be852c9792cbcb76381dcc9c2104049364ea0..15cd666d680b9eb85f2958bed2711c8a220ee5d0 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise42.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise42.cpp @@ -382,6 +382,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise43.cpp b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise43.cpp index ceb41ff74744c9f2c3bd6e1f931e681d43aad66d..a4556285eab6d5ff894cf8343b0db38f46abef1b 100644 --- a/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise43.cpp +++ b/HandsOn/5-UsefulConceptsAndSTL/Solution/exercise43.cpp @@ -383,6 +383,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/HandsOn/6-InRealEnvironment/Solution/Exercise44/PowerOfTwoApprox.hxx b/HandsOn/6-InRealEnvironment/Solution/Exercise44/PowerOfTwoApprox.hxx index d6d4fc099ae0c2aae0066ecf823ce0dca7af4fcb..83926a8b5f9dbeade0a41d12a1c430ec31bd7c71 100644 --- a/HandsOn/6-InRealEnvironment/Solution/Exercise44/PowerOfTwoApprox.hxx +++ b/HandsOn/6-InRealEnvironment/Solution/Exercise44/PowerOfTwoApprox.hxx @@ -21,6 +21,8 @@ PowerOfTwoApprox<IntT>::PowerOfTwoApprox(int Nbits, double value) } while (numerator <= max_numerator); + // After the while loop we have numerator > max_numerator, + // hence we need to update the fraction using the previous exponent with --exponent. HelperComputePowerOf2Approx(value, --exponent, numerator, denominator); } diff --git a/bibliography.ipynb b/bibliography.ipynb index 6ede479345db32992d4a7c8a2bedd0beeb2133f8..4fa48c4d673085746dad34c05c01f6344860ec82 100644 --- a/bibliography.ipynb +++ b/bibliography.ipynb @@ -117,7 +117,11 @@ "\n", "### [SED Saclay technology watch](https://sed.saclay.inria.fr/kw_c++.html)\n", "\n", - "In the experimentation and development departement ([SED](http://sed.saclay.inria.fr/)) at [Inria Saclay](https://www.inria.fr/centre/saclay), we publish about each week few links we found interesting. C++ is rather often mentioned; the link above provides all such links related to C++ since we started doing so." + "In the experimentation and development departement ([SED](http://sed.saclay.inria.fr/)) at [Inria Saclay](https://www.inria.fr/centre/saclay), we publish about each week few links we found interesting. C++ is rather often mentioned; the link above provides all such links related to C++ since we started doing so.\n", + "\n", + "### [C++ Weekly With Jason Turner](https://www.youtube.com/@cppweekly)\n", + "\n", + "A youtube channel covering various aspects of very modern C++, with a new episode uploaded weekly. Each episode focuses on one specific topic and keeps it short (5 to 10mn videos)." ] }, {