« The Catch for Multi-threading Decision Making | Main | Sponsored Feature: Multi-Core Simulation of Soft-Body Characters Using Cloth »

Visualizing Floats

visualizing_floats.jpgFloating point numbers permeate almost every area of game programming. They are used to represent everything from position, velocity, and acceleration, to fuzzy AI variables, texture coordinates, and colors.

Yet, despite their ubiquitous role, few programmers really take the time to study the underlying mechanics of floating point numbers, their inherent limitations, and the specific problems these can bring to games.

As an independently written article, Neversoft co-founder and veteran programmer Mick West lays out the specifics to help visualize the problems with floats in a new article that starts off as follows:

"A float consists of 32 bits: a sign bit, an 8-bit exponent (e), and a 23-bit significand (s).

To visualize the problems with floats, it's useful to visualize the differences between floats and integers. Consider how the 32-bit integers represent space. There are 232 integers; each one can be thought of as representing a region between two points on a line.

If each integer represents 1 millimeter, then you can represent any distance using integers from 1mm to 232mm. That's any distance up to about 4,295km, about 2,669 miles, with a resolution of 1mm."

You can now read the full Gamasutra feature on visualizing floats, floats versus integers and other useful calculations (no registration required, please feel free to link to this feature from other websites).

Comments

It’s unfortunate that the latest graphics hardware is now hardwired to exclusively use floats in shader operations.

Post a comment

About

This specially written weblog combines Gamasutra and Intel knowhow to present and deconstruct the latest happenings in visual computing and game technology.

Editor: Eric Caoili

Recent Comments