Recent

Author Topic: project.exe raised exception class 'external:SIGFPE'  (Read 21762 times)

tarounen

  • New Member
  • *
  • Posts: 17
project.exe raised exception class 'external:SIGFPE'
« on: May 02, 2012, 06:48:20 pm »
hi, its me again. i have this error:"project.exe raised exception class 'external:SIGFPE'" while running these codes in my program.
Code: [Select]
procedure findz;
begin
  z2:=0.0000;
  equA:=((1/sqrt(2*pi))*((EXP(-0.5*sqr(z2)))/(-z2)));
  prob:=strtofloat(frm.eA.caption);
  while equA<prob do
    begin
      z:=z2+0.0001;
    end;
  frm.ansz.caption:=floattostr(z2);
end; 

can anyone help mw to fiz this!

BlueIcaro

  • Hero Member
  • *****
  • Posts: 820
    • Blog personal
Re: project.exe raised exception class 'external:SIGFPE'
« Reply #1 on: May 02, 2012, 07:19:01 pm »
Try to put a break point at the first line. Then run your application. When stops at the break point, try to run it step by step (F8), to see in what line is the problem.

Also, please, report your version of Lazarus and OS.

/BlueIcaro

Edit:
your code
Code: Pascal  [Select][+][-]
  1. procedure findz;
  2. begin
  3.   z2:=0.0000;
  4.   equA:=((1/sqrt(2*pi))*((EXP(-0.5*sqr(z2)))/(-z2)));
  5.  
Your making a division by Zero!!!
« Last Edit: May 02, 2012, 07:21:46 pm by BlueIcaro »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11361
  • Debugger - SynEdit - and more
    • wiki
Re: project.exe raised exception class 'external:SIGFPE'
« Reply #2 on: May 02, 2012, 07:20:05 pm »
Code: [Select]
z2:=0.0000;
  equA:=((1/sqrt(2*pi))*((EXP(-0.5*sqr(z2)))/(-z2)));

Looks to me like you divide by zero.

If you rather want a result like NaN,there is some way in the unit math to change that... (not sure about the exact way)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 820
    • Blog personal
Re: project.exe raised exception class 'external:SIGFPE'
« Reply #3 on: May 02, 2012, 07:24:36 pm »
Martin, you didn't give me time to edit my post  :)

In other way, I think that's a wrong code, because he put the var z2 to 0, and then make a division  :-[

/blueIcaro

tarounen

  • New Member
  • *
  • Posts: 17
Re: project.exe raised exception class 'external:SIGFPE'
« Reply #4 on: May 02, 2012, 07:57:45 pm »
thanks, what a silly mistake. i didn't saw that, :o

actually i think that i have not written the code properly as the program is taking too much time to process. Anyway thanks again for your help.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11361
  • Debugger - SynEdit - and more
    • wiki
Re: project.exe raised exception class 'external:SIGFPE'
« Reply #5 on: May 02, 2012, 08:21:29 pm »
thanks, what a silly mistake. i didn't saw that, :o

actually i think that i have not written the code properly as the program is taking too much time to process. Anyway thanks again for your help.

Actually, I wouldn't be surprised if it runs forever....

Code: [Select]
  while equA<prob do
    begin
      z:=z2+0.0001;
    end;

This is an endless loop, unless equA or prob  are functions (part of a property) and there calculation includes z or z2

equA or prob   are not modified in the loop....

And also, if z and z2 are variables, z2 does not change, so the result for z is always the same
« Last Edit: May 02, 2012, 08:23:20 pm by Martin_fr »

 

TinyPortal © 2005-2018