LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Floating point exception error (https://www.linuxquestions.org/questions/linux-newbie-8/floating-point-exception-error-711931/)

mathb 03-16-2009 06:56 AM

Floating point exception error
 
Hi all,

When i try to run my application on an arm board with linux OS , the application crashes with floating point exception .

Could someone tell me why would a floating point exception occur in general .

Thanks

akuthia 03-16-2009 08:39 AM

google is thy friend

Quote:

Also, five types of floating-point exception are identified:

* Invalid. Operations with mathematically invalid operands--for example, 0.0/0.0, sqrt(-1.0), and log(-37.8)
* Division by zero. Divisor is zero and dividend is a finite nonzero number--for example, 9.9/0.0
* Overflow. Operation produces a result that exceeds the range of the exponent-- for example, MAXDOUBLE+0.0000000000001e308
* Underflow. Operation produces a result that is too small to be represented as a normal number--for example, MINDOUBLE * MINDOUBLE
* Inexact. Operation produces a result that cannot be represented with infinite precision--for example, 2.0 / 3.0, log(1.1) and 0.1 in input

The implementation of the IEEE standard is described in the Sun Numerical Computation Guide.
Basically, it looks like it amounts to performing a math equation that your math teacher would've yelled at you in highschool for.

salasi 03-17-2009 03:12 AM

Isn't it also possible that you have compiled your app with compiler options that assumes there is a floating point processor present and you don't have one on your ARM board? More info on your target hardware, please?

niamov 05-26-2011 07:55 AM

Hello,

I dig up this old thread : I am in the same situation as mathb 2 years ago :
I try to run my application on an arm board with linux OS and the application crashes sometimes (rare) with floating point exception.
There is a dividing operation in the code, (random division) but I check that it is not a zero divide.
What seems the more probable is "Inexact" type reported by akuthia... But I don't really understand why "Inexact" type is a problem? i.e why making operation 2.0 / 3.0 should crash the application? In my mind the result should just be truncated to 0.6666667 ....

Thanks

akuthia 05-27-2011 02:12 AM

In your mind, it does get truncated, a computer doesnt have a "mind" to truncate it, unless it was specifically programmed to do so, thus the error.

niamov 05-27-2011 03:36 AM

Okay, I made a quick hello world test with 2.0/3.0 operations and with my environment, it is truncated to 0.666667 .
So there is no problem with that.
I found my error which was finally a 0 divide operation not properly managed in a specific case.
Thank you.


All times are GMT -5. The time now is 01:39 PM.