Closed dullin closed 2 years ago
I debated for a while whether to put in the cast or to just make HP
and MaxHP
be float
values. I eventually settled on the second. HP seems like something that would typically not support fractional values, though it isn't impossible. I initially tried the casting solution, but it wasn't just a single place, but about five. And the deciding factor was that they all were in expressions that were already quite complicated, becoming even more complex with the cast. Only the rest of the complexity was to illustrate the features being discussed in the chapter, while the cast was essentially just noise that clouded the key points of the code snippet.
Page 337 of Level 42 has a query expression that create a ratio from two ints. Those need to be casted to have a value other than 0.
Code excerpt
The same calculation is used on page 339.