[fpc-pascal] Sin function

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Wed Dec 29 13:24:52 CET 2010


faber wrote:
>> If I were you I would print it with more digits so you see if there is any
>> significant difference at all.
> 
> ok I understand, I was suggested by
> http://www.freepascal.org/docs-html/rtl/system/sin.html where it is
> given score 0.0 for Writeln (Sin(Pi):0:1);

Transcendentals are a can of worms. Without and with formatting 
respectively,

ARM, PowerPC, SPARC:

  1.22464706384516E-016
0.0

x86 (P-III):

-5.4210108624275222E-0020
-0.0

All FPC 2.4.2 on Linux. The result /should/ be zero, and x86- which I 
presume is what you're running- is nearer zero than the others :-)

There are lots of issues here, including the number of bits used 
internally by the floating point hardware and whether it knows Pi to 
this degree of precision. Also it might depend on optimisation level etc.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list