Floating point performance issue

David Brown david.brown@hesbynett.no
Mon Dec 26 13:00:00 GMT 2011


On 26/12/11 02:15, Vincent Lefevre wrote:
> On 2011-12-24 12:11:06 +0100, David Brown wrote:
>> On 23/12/11 21:25, Vincent Lefevre wrote:
>>> [*] This example isn't much different from
>>>
>>>    http://www.ima.umn.edu/~arnold/disasters/patriot.html
>>>
>>> (where all calculations could have been done exactly, if the code
>>> were better designed), which lead to 28 people killed.
>>
>> This is an example where floating point should not have been used - no
>> compiler can warn about such inappropriate use of tools and lack of
>> understanding about the job in hand.
>
> Actually it wasn't floating point, but fixed point, i.e. something
> like scaled integers. Anyway the problem is the same, whether it is
> implemented in fixed point or floating point: an initial error that
> accumulates... Now, since you can also use integers to represent
> approximations of real values (planes, at least not the latest ones,
> use integer arithmetic for their calculations, so you see...), would
> you also ban the equality test on integers?
>

No, integer arithmetic is well-defined and consistent.  However, I would 
put big question marks about code that relied on the accuracy of 
division, since it generally can't be done exactly in integers.  But 
that's a matter of writing the code correctly, and problems should be 
spotted by code reviews rather than the compiler.

>> In defence of the programmer, however, it should be noted that the Patriots
>> were never designed for intercepting Scuds, and there were a lot of reasons
>> why they did a poor job of it (with issues in the software, electronics and
>> mechanics).
>
> If the limitations were properly documented, users would have detected
> the potential failure. Or perhaps they didn't RTFM. :)
>

I don't know the details of how the Patriots ended up being used here 
(though I do know someone who does).  It could have been something as 
obvious as "we know they are not ideal, but they are the best we have". 
  Success rates of Patriot interception of Scuds was somewhere between 
0% and 97%, depending on who you ask and how you measure it.  Of course, 
if both sides believed them to be successful at the time, then they 
/were/ successful in some ways - regardless of algorithm errors.

I think this is getting a touch off-topic for this newsgroup, however.




More information about the Gcc-help mailing list