#1 2018-09-08 04:05:57

ComingNine
Member
Registered: 2010-07-29
Posts: 294

ExtendedToStr behaves inconsistently between FPC and Delphi

As shown in the sample code on gist , the ExtendedToStr behaves inconsistently between FPC and Delphi. Could you help to suggest the workaround ?

PS: FloatToStrF and Format seem to behave inconsistent within FPC, and between FPC and Delphi.

Offline

#2 2018-09-08 07:57:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ExtendedToStr behaves inconsistently between FPC and Delphi

Yes, this is a known inconsistency, since they have two diverse implementations.

Offline

#3 2018-09-08 10:13:32

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: ExtendedToStr behaves inconsistently between FPC and Delphi

ab wrote:

Yes, this is a known inconsistency, since they have two diverse implementations.

Sad to hear. It should be noted that ExtendedToStr behaves also inconsistently between Delphi25Tokyo's Win32 and Win64.

Offline

#4 2018-09-08 10:57:29

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: ExtendedToStr behaves inconsistently between FPC and Delphi

Dealing with floating with big precision is always a problem. In our applications we try to avoid it by limiting precision part to maximum 4 digits and adding division(factor). For example if we need to store 8 digits precision (0.66599631)  we store 2 field {value: 6659.9631, factor: 10000}. Hope it's help

Offline

#5 2018-09-08 15:07:07

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: ExtendedToStr behaves inconsistently between FPC and Delphi

mpv wrote:

Dealing with floating with big precision is always a problem. In our applications we try to avoid it by limiting precision part to maximum 4 digits and adding division(factor). For example if we need to store 8 digits precision (0.66599631)  we store 2 field {value: 6659.9631, factor: 10000}. Hope it's help

Many thanks for your clever experience ! Is it because a number with maximum 4 digits can be exactly represented as Currency type ?

Offline

#6 2018-09-09 09:32:07

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: ExtendedToStr behaves inconsistently between FPC and Delphi

This is not related to Delphi, but for how FPU works with floating.

Offline

Board footer

Powered by FluxBB