[Lazarus] Problem with fpc-3.0.4 and double

zeljko zeljko at holobit.net
Fri Feb 2 16:28:01 CET 2018


On 02/02/2018 04:10 PM, Marco van de Voort wrote:
> On Wed, Jan 31, 2018 at 07:31:56PM +0100, zeljko via Lazarus wrote:
>>> Using binary floats, there are just too many values that can't be
>>> represented 100%, regardless of the length of the mantissa.
>>> https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems
>>
>> Thanks Ralf, I know what is floating point arithmetic, but something is
>> changed between 3.0.2 and 3.0.4 and I want to know what it is.
> 
> It could be as simple as slightly different codegeneration that eliminates a
> temporary variable or adds it.
> 
> The x87 CPU calculates with 80-bits, but storing it into a double variable
> (e.g.  a local variable on the stack) will round it to 64-bit double. This
> can cause small precision fluctuations, and, as with all regular float
> comparison issues, it is something of all times and all compilers.
> 

Today I've found exact where's problem.
It's zeoslib 7.2.1 which uses fastcode (ZFastCode) implementation and 
results of StrToFloatDef() are bit different than results which is given 
by fpc's StrToFloatDef().
Changed code to use fpc functions and everything is correct now :)

Thanks for your time ppl

zeljko




More information about the Lazarus mailing list