Skip to content
Permalink
Browse files
add a summary at the end
  • Loading branch information
James Brusey committed Jun 29, 2022
1 parent b8cb9f4 commit 601e78e0ca0097c165b1577d0a5c6e4d9235cc31
Showing 1 changed file with 18 additions and 0 deletions.
@@ -185,3 +185,21 @@ struct decimal *convert_temperature(struct decimal *dp, uint16_t v)
return dp;
}
#+END_SRC
** Think about the maths
Perhaps it would have been better to understand the maths involved before trying to write the code.

That is, we wish to find the integer solutions $a$, $b$ to:
\[ a + b/100 = x / 100 - 39.6 \]
for integer values of $x$ in the range $[0, 65536)$.

I leave it to the reader to try and find the full solution. Possibly this solution will be neater than our final version above!
* Summary
Although it can be daunting to set up your first test case, once you have done it, additional test cases are much easier.

The advantage of working this way is that it /becomes/ much faster to develop correct code even though it may be slightly slower to begin with.
I encourage you to stick with it!

* Further exercises
As a further exercise, you might like to test out the next function that we need to write, which is to print out the integer and fractional part on the screen using =printf=.
As a first go, you may find it easier just to manually check that it prints the right output.
It is possible to automatically check the output but this requires you to "mock" =printf=.

0 comments on commit 601e78e

Please sign in to comment.