Analysis of the report of Andrey Akinshin about arithmetic
Hello everyone, ready for another analysis. Today we are going to watch the report not with the JPoint, but with DotNext! The author of the report is Andrey DreamWalker Akinshin, and his presentation is devoted to the details of the implementation of floating-point arithmetic in .NET:
Disclaimer: about the implementation of arithmetic, only the report itself, and not the article itself.
Plot
At this point, I must say that I don’t really like puzzlers. They require the knowledge of the dark parts of the specification, which in real life is usually useless. Just imagine that you are accompanying code written by a lover of riddles.
Note, make the person think about something important before telling him “how to” - in general, it’s good, he will remember the result much better. But to begin with the essence, that is, choosing the knowledge that needs to be conveyed to people, and illustrating it with a paradoxical task with simple conditions is difficult. For puzzlers, it is often easier to take those things that are not very critical to remember, but nobody knows them, and make them pure entertainment. ')
In general, an attentive reader will easily trace my dislike for the genre in this article.
Story Moves and Actors
Is there a contradiction here: assistants come to the scene to create the illusion of competition, but it is clear that the answers and transitional replicas between tasks are known in advance. For example, at 12: 00-12: 20 Julia argues that coercion to the whole is not the operation, and you need to use rounding, and then the next task appears, just for rounding. In such situations, I would change the order of the tasks so that the topic that allegedly “came to mind” to the assistant did not arise immediately, but a little later. For greater likelihood, assistants might sometimes agree with each other.
Also it seems to me that unfortunate cameo Andrei Dmitriev (39:00). It is clear why this scene is needed: to advertise the next DotNext and the next report. But since we say that the time is over, although there are still problems, then let everything look as if it were true. First, speak "under the edge" and do not say that we have a few more minutes to ask questions. Secondly, to light two or three additional tasks with answers and to squander slides with them at the moment of interruption. Then the people, you see, will be interested, suddenly the Zeigarnik effect will still work, they will swing the presentation, all is well.
And so I was left wondering: what was it all about? Integral more ...
Not only how, but why
In some places I didn’t have enough understanding of what exactly the specification developers were smoking. Why did they do it like that? This would help not only to memorize better, but also to separate important tasks from random nonsense. Consider, for example, the previously mentioned rounding (starts at 12:20):
Where did the rounding to the nearest even come from? Why is it enabled by default? When is the “away from zero” mode needed? Perhaps only I missed everything, but normal people have long known, but I interpreted this question for the first time in my life when preparing this analysis. It turns out that the regime is called “banking rounding” and was invented mainly for cases when you need to add money with cents / kopecks in the fractional part. Since there are only 100 different cents, a tail of exactly 50 cents will occur quite often in a random set of cash sums. If all of them are rounded off from zero, we will accumulate a systematic error, and if to the nearest even, then the rounding errors will be averaged to about zero. In addition, each specific number is rounded deterministically, and not in a random direction (and that is, this approach).
Since counting money using float and double does not follow for many reasons, the default settings look illogical. But at least it is clear what is behind them. And if someone knows another realistic scenario for using banking rounding, share, please.
It seems to me, to raise the logic behind the specification and tell it to the audience is useful and good. It is much more convenient to memorize not only facts, but also their reasons.
Now who will remember the truth table for the operations from exercise 8 (beginning 17:23), although it was in the presentation?
Is it generally important to know? If you could understand the usage scenarios that the developers had in mind, it would be easier to restore it.
The relevance of exercise 10, on the contrary, is not questioned (beginning at 21:18):
Andrei tells you in what situations you can step on the problem with OverflowException and ends the story with an optimistic wish to be careful. And did everyone immediately understand how exactly you need to be careful? There would not have prevented the details.
How does the float
Of course, in the university we had fragments of courses, or even whole courses dedicated to the presentation of data. And of course, they told us about floating point numbers, but without practice, a lot is forgotten. In some tasks, Andrew touches upon the fundamental properties of the float and double type and the problems arising from them, but does not quite focus the attention of viewers on this. The most striking example is the problem of associativity (exercise 14, beginning at 31:30):
Considering that not everyone in the hall answered correctly, the material of the first or second year is worth refreshing. In this case, it is important that the numbers are unevenly distributed: the farther from zero, the greater the gaps between them. Let's consider two adjacent floats of the maximum order (double in meaning are the same, just draw more):
From the point of view of the considered format there is nothing between them. In this case, in the real world, the first number is 1.7014122 * 10 38 , the second is 1.701412 * 10 38 , and the difference between them is 0.0000002 * 10 38 . This is, let's say carefully, awesome lot. It is impossible to add to the maximum order number one, a thousand or even a billion.
Knowing this mechanic, it is easy to understand how the associativity rule is violated: the sum of several small numbers may be greater than the distance between two adjacent large ones, whereas each small number will be simply destroyed if you start addition from a large number.
findings
In general, each puzzler is a fascinating story that gives the speaker credit to the attention of the audience, and this credit can be used to bring out any morality from at least some of the riddles (it really is there!). I am sure that the report would benefit from this.
Slides
Slides are made well, so I will not quibble over trivialities, but I will note solutions worthy of emulation.
Sequential appearance of slide elements
The report has a lot of slides with a lot of information. Immediately everything on the screen is difficult to see and understand, but Andrei has all the elements in turn. Thus, the viewer at no time loses the place that you need to look at and which the speaker is talking about. This greatly facilitates the perception of large schemes, pieces of code, lists. Do as Andrew.
Uniformity
Suppose there are almost no funny pictures in the presentation, except for Homer Simpson (who, in principle, could be searched for in a better resolution) and integral, it doesn’t become less fun. Math itself is fun.
In addition, each exercise is designed in the same way, the solution is allocated the same way, the explanation is marked in the title of the slide - the viewer quickly gets used and nothing distracts him from solving puzzles. If you have a presentation of many small stories, it makes sense to stick to a similar design, as in this case.
Regular Parsing
If you want to get feedback on your performance, I’ll be happy to give it to you.
What is needed for this?
Link to the video recording of the speech.
Link to slides.
Application from the author. Without the consent of the speaker himself, we will not analyze anything.
All this needs to be sent to the habrauzer p0b0rchy , that is, to me. I promise that the review will be constructive and polite, as well as highlight the positive aspects, and not just what needs to be improved.