> Probably the last floating point operation before the function call to AmpHoursRemainingSet is invalid
This is exactly what happened. I did not think about evaluating previous operations. Thanks!
Main Topics
Browse All Topics
Hi,
All right, I'm stumped on this one. I am using C++ Builder 6, and I keep getting the 'Invalid floating point operation' exception when I execute a certain line of code.
I am calling the following member function:
AmpHoursRemainingSet(0.0);
which looks like
void MyClass::AmpHoursRemaining
{
if (0.0 > 3.3)
{
value = AD_NEW_BATTERY_MAXIMUM_AMP
}
if (value > 3.3)
{
value = AD_NEW_BATTERY_MAXIMUM_AMP
}
}
Whenever the second if statement is executed, the exception occurs. (I put the first if statement in to verify the values are not causing the problem).
I have absolutely no idea why this may be occurring -- or how I can go about debugging this. I have not had any problems with floating point types in Borland before, so I do not know why it is occurring with this application.
Also, this happens in a number of spots -- sometimes with comparisons, sometimes with assignments. If I hard-code numbers in, the problem disappears.
Any thoughts/comments would be great.
Thanks,
Jeff
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: cwwkiePosted on 2006-01-04 at 10:24:28ID: 15610171
Probably the last floating point operation before the function call to AmpHoursRemainingSet is invalid. For example because NaN is used in a operation. When you use hard-coded numbers, the compiler will evaluate the expression, and no floating point operation is generated.
com/ccalve rt/TechPap ers/ Floati ngPoint.ht ml):
Owner)
blog/pivot /entry.php ?id=53
You can avoid it by remasking the fpu exceptions (http://homepages.borland.
#include float.h
__fastcall TForm1::TForm1(TComponent*
: TForm(Owner)
{
_control87(MCW_EM, MCW_EM);
}
Here is a related story: http://www.virtualdub.org/