Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-05

SIGFPE with SameValue()

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

Hi List.

I have discovered the following strange bug/problem.

Please check out the following program and tell me which part is right and which is wrong,
or perhaps what i'm doing wrong in this case.

program project1;
{$mode objfpc}{$H+}
uses
   math;
var
   a,b: extended;
begin
   if SameValue(1, MaxFloat) then  // This works?
     Writeln('Same')
   else
     WriteLn('Fail');
   a := 1;
   b := MaxFloat;
   if SameValue(a,b) then  // But this fails in SameValue with SIGFPE???
     Writeln('Same')
   else
     WriteLn('Fail');
end.

My setup :

Free Pascal Compiler version 2.6.0 (from:
http://svn.freepascal.org/svn/fpc/tags/release_2_6_0) Compiler Date : 2012/01/19
Compiler CPU Target: x86_64

FPC Compiled with extra options "-g -gl -godwarfsets",

Kind regards,
Torsten Bonde Christiansen

Torsten Bonde Christiansen
to Jonas Maebe
Jonas Maebe wrote 11 lines
Torsten Bonde Christiansen wrote on Thu, 10 May 2012: > On 2012-05-10 10:45, wrote: >> it seams that MaxFloat get MaxDouble (FPC_HAS_TYPE_DOUBLE is defined) >> but SameValue uses as Single when overload. >> Works with SameValue(double(a),double(b),double(0)). > > How can that be, since I use Extended as type? http://bugs.freepascal.org/view.php?id=21199

Thanks. I can see that addid 0.0 to SameValue solves the problem. :)

Regards,
Torsten.