Category Archives: Floating Point

Please Calculate This Circle’s Circumference

“Please write a C++ function that takes a circle’s diameter as a float and returns the circumference as a float.” It sounds like the sort of question you might get in the first week of a C++ programming class. And … Continue reading

Posted in Floating Point, Programming | Tagged , , , | 46 Comments

There are Only Four Billion Floats–So Test Them All!

A few months ago I saw a blog post touting fancy new SSE3 functions for implementing vector floor, ceil, and round functions. There was the inevitable proud proclaiming of impressive performance and correctness. However the ceil function gave the wrong … Continue reading

Posted in Floating Point | Tagged , | 26 Comments

Floating-Point Determinism

Is IEEE floating-point math deterministic? Will you always get the same results from the same inputs? The answer is an unequivocal “yes”. Unfortunately the answer is also an unequivocal “no”. I’m afraid you will need to clarify your question. My … Continue reading

Posted in Floating Point, Visual Studio | Tagged | 38 Comments

Float Precision Revisited: Nine Digit Float Portability

Last year I pointed out that float variables can be converted to text and then back to the same binary value using printf(“%1.8e”). You can also use %.9g for more compact results. I also supplied a test program that used … Continue reading

Posted in Floating Point | Tagged , , , , | 13 Comments

Top Eight Entertaining Blog Facts for 2012

The end of the year is a traditional time for lists and I thought I’d do a post just to summarize the most interesting or surprising things that I discovered while writing this blog during 2012.

Posted in Bugs, Floating Point, Performance, Programming | Tagged , , , | 1 Comment

Game Developer Magazine Floating Point

This is for references, code examples, and discussion regarding the floating-point article in the October 2012 Game Developer Magazine.

Posted in Floating Point | Tagged | 3 Comments

Doubles are not floats, so don’t compare them

I’ve seen a few online discussions linking to my Comparing Floating Point Numbers page for misguided reasons and I wanted to discuss those reasons to help people understand why throwing epsilons at the problem without understanding the situation is a … Continue reading

Posted in Floating Point, Programming | Tagged , , , , | 17 Comments

Floating-Point Poetry

I gave a talk at iFest on Saturday that briefly covered some performance and precision issues taken from my series of floating-point blog posts. My talk was after Ed Fries, who did a brilliant talk on art and constraints, centered … Continue reading

Posted in Floating Point | Tagged , | 3 Comments

That’s Not Normal–the Performance of Odd Floats

Denormals, NaNs, and infinities round out the set of standard floating-point values, and these important values can sometimes cause performance problems. The good news is, it’s getting better, and there are diagnostics you can use to watch for problems. In … Continue reading

Posted in AltDevBlogADay, Floating Point, Performance, Programming | Tagged , , , , , | 10 Comments

Exceptional Floating Point

Floating-point math has an answer for everything, but sometimes that’s not what you want. Sometimes instead of getting an answer to the question sqrt(-1.0) (it’s NaN) it’s better to know that your software is asking imaginary questions. The IEEE standard … Continue reading

Posted in AltDevBlogADay, Floating Point, Programming | Tagged , , , , | 22 Comments