Floating point arithmetic is… at its worst when it is expected to model the interactions of quantities expressed as decimal strings that are expected to be exact.

Floating point – Wikipedia, the free encyclopedia

I’m running into this problem at work, where adding float values together results in slightly incorrect arithmetic. For example, for a given situation, I’m expecting the value 40.41, but the float value is stored as 40.40995. To work around this, I’ve had to round information to two decimal places after finishing sets of math operations. Kludge!

We will need to think about using decimal values instead of floats due to float’s arithmetic issues.

Blogged with Flock

Tags: programming