[fpc-pascal] round(2.5)=2

Klaus Hartnegg hartnegg at gmx.de
Tue Jun 12 23:58:34 CEST 2018


Am 12.06.2018 um 23:24 schrieb Jonas Maebe:
> On 12/06/18 23:12, Klaus Hartnegg wrote:
>> This behaviour does have advantages in the special case of adding up 
>> many rounded numbers, but it ruins the graphics output of my software. 
>> It should at least be configurable. And in {$mode tp} it should behave 
>> like Turbo Pascal, because that's what this mode is made for.
> 
> The basic issue is that FPC doesn't support the 6 byte real type used by 
> TP in {$n-}, nor the associated behaviours such as rounding, 
> range/precision cut-offs etc. FPC indeed can only support TP {$n+} mode 
> compatibility at this time (and even that is not always exact, as it 
> depends on the FPU precision support by the hardware and OS).

Nevertheless it could offer an option to use the other rounding method.

Yes, there would still be deviations in some math results, because of 
the different precision. But these deviations are much smaller than 
those from the other rounding method.

Klaus



More information about the fpc-pascal mailing list