Chapter 9. Floating-Point Math in C


Chapter 9. Floating-Point Math in C++

This chapter introduces floating-point math.

Oh, No! Not MATH!

Yes, it's true. A certain amount of math is involved in games. For many types of games, the math you have to do is very straightforward and minimal. So if you're not a student of advanced math, don't worry. Most of the math you'll do is just addition, subtraction, multiplication, and division. Having said that, however, you can't avoid floating-point math if you're going to become a game programmer. Floating-point numbers and floating-point math are used in physics. In previous chapters, we simulated the movement of a ball in the Ping game by using just integers. However, the movement of that ball is not very complex. In fact, it's not actually all that realistic. You can get more realistic results with floating-point math.

Previous chapters mentioned that floating-point numbers are numbers that contain a fractional part. However, that is only the most basic definition of floating-point numbers. You must know how C++ implements floating-point numbers to use them well and to avoid the problems you can have with them.

This chapter provides a fairly detailed overview of floating-point numbers in C++. It demonstrates their use by showing you how to do realistic (but surprisingly simple) physics with floating-point numbers.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net