22.17. Real numbers

Simulations work better with real numbers, and there is a Real type and some macros we use in our programs, so we’re going to have a file called RealNumber.h which we include in our files using real numbers. (If we didn’t want to do all those includes, we could have put the #include “realnumber.h” somewhere inside of the StdAfx.h file, for instance right before the line that says //{{AFX_INSERT_LOCATION}}.)

In our code we use Real as another word for double or for float. To give ourselves the freedom to switch between double and float, depending on whether we have a greater need for accuracy or for speed, we have a line saying typedef double Real or typedef float Real inside RealNumber.h.

 #ifndef REALNUMBER_H #define REALNUMBER_H ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.