Original Post
Hi, I read an article on self-documenting code recently, and one point they made is that intermediate variables can help to make it more accurate and readable. For example, replace: float radiusSquared = maxExtent * 1.41f; radiusSquared *= radiusSquared; with: float radius = maxExtent * 1.41f; float radiusSquared = radius * radius; The advantage of the 2nd one is that it's more precise... The 1st one can be a little confusing because the 1st line of code is setting "radiusSquared" equal to a value which is actually just the radius. In an example like this, the intent is clear but I can imagine it would become problematic in a more hairy piece of code... So my question is, is it okay to use intermediate values like this? Is the compiler clever enough to optimize away intermediates so that the 2nd example would be as efficient as the first one? Thanks, roos