Re: [fpc-pascal] round(2.5)=2

2018-06-14 Thread wkitty42
On 06/13/2018 04:17 AM, Michael Schnell wrote: On 12.06.2018 23:12, Klaus Hartnegg wrote: No, it does not depend on the hardware, but on the setting of $N. Turbo Pascal with $N+ rounds like FreePascal. But the default is $N-. In this mode Turbo Pascal always rounds up. What exactly does $N

Re: [fpc-pascal] round(2.5)=2

2018-06-14 Thread Michael Schnell
On 12.06.2018 23:12, Klaus Hartnegg wrote:   writeln (round(a*1.1)); As with usual float formats 1.1 can't be represented exactly, the result can't be considered any precise value. -Michael ___ fpc-pascal maillist -

Re: [fpc-pascal] round(2.5)=2

2018-06-14 Thread Michael Schnell
On 12.06.2018 23:12, Klaus Hartnegg wrote: No, it does not depend on the hardware, but on the setting of $N. Turbo Pascal with $N+ rounds like FreePascal. But the default is $N-. In this mode Turbo Pascal always rounds up. What exactly does $N in Turbo pascal mean ? Obviously it in this

Re: [fpc-pascal] round(2.5)=2

2018-06-14 Thread Michael Schnell
On 12.06.2018 23:12, Klaus Hartnegg wrote: The only *reliable* solution appears to be compiling a modified version of FreePascal. It would make the round function a lot slower not to simply rely on the hardware. And in fact the only *reliable* solution is *not ever* to rely on exact values

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Florian Klämpfl
Am 13.06.2018 um 22:19 schrieb Marco van de Voort: In our previous episode, Florian Kl?mpfl said: In our previous episode, Sven Barth via fpc-pascal said: Which is what FPC already provides with SetRoundMode() in unit Math. As long as one changes the rounding mode only locally for some

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Marco van de Voort
In our previous episode, Florian Kl?mpfl said: > > In our previous episode, Sven Barth via fpc-pascal said: > >> Which is what FPC already provides with SetRoundMode() in unit Math. > >> > >> As long as one changes the rounding mode only locally for some calculations > >> and restores it

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Florian Klämpfl
Am 13. Juni 2018 5:39:08 nachm. schrieb mar...@stack.nl (Marco van de Voort): > In our previous episode, Sven Barth via fpc-pascal said: >> Which is what FPC already provides with SetRoundMode() in unit Math. >> >> As long as one changes the rounding mode only locally for some calculations >>

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said: > Which is what FPC already provides with SetRoundMode() in unit Math. > > As long as one changes the rounding mode only locally for some calculations > and restores it afterwards there should be no problem (the rounding mode > can be

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Santiago A.
El 12/06/2018 a las 23:12, Klaus Hartnegg escribió: Am 11.06.2018 um 10:01 schrieb Michael Schnell:  - the way of rounding is defined by the CPU hardware, even old Turbo Pascal executables do banker's rouding on modern hardware. No, it does not depend on the hardware, but on the setting of

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Sven Barth via fpc-pascal
Wolf schrieb am Mi., 13. Juni 2018, 09:27: > Why not ask the CPU to do the rounding? This is what Intel offers in > volume 1 of the Intel ® 64 and IA-32 Architectures Software Developer's > Manual: > 4.8.4.1 > Rounding Control (RC) Fields > In the Intel 64 and IA-32 architectures, the rounding

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Wolf
Why not ask the CPU to do the rounding? This is what Intel offers in volume 1 of the Intel ® 64 and IA-32 Architectures Software Developer's Manual: 4.8.4.1  Rounding Control (RC) Fields In the Intel 64 and IA-32 architectures, the rounding mode is controlled by a 2-bit rounding-control (RC)

Re: [fpc-pascal] round(2.5)=2

2018-06-13 Thread Michael Schnell
On 12.06.2018 09:01, Mattias Gaertner wrote: Floats can represent 1.5 exactly. Of course I do know how the binary representation of floats is done on X86 and similar architectures, and hence that same provides a bit combination that exactly defines 1.5. That is why I did say *relying* on the

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread Klaus Hartnegg
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

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread 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

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread Klaus Hartnegg
Am 11.06.2018 um 10:01 schrieb Michael Schnell:  - the way of rounding is defined by the CPU hardware, even old Turbo Pascal executables do banker's rouding on modern hardware. No, it does not depend on the hardware, but on the setting of $N. Turbo Pascal with $N+ rounds like FreePascal. But

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread Klaus Hartnegg
Am 12.06.2018 um 09:01 schrieb Mattias Gaertner: IMHO this is not really relevant, as relying on the exact value of a real number is erroneous, anyway. So a real number never can be considered to *exactly* *be* 1.5, but just somewhere nearby, and hence it's not legal to predict hat it is rounded

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread Mattias Gaertner
On Mon, 11 Jun 2018 10:01:13 +0200 Michael Schnell wrote: > There has been a long winding discussion on the German Forum. > > IMHO this is not really relevant, as relying on the exact value of a > real number is erroneous, anyway. So a real number never can be > considered to *exactly* *be*

Re: [fpc-pascal] round(2.5)=2

2018-06-12 Thread Michael Schnell
There has been a long winding discussion on the German Forum. IMHO this is not really relevant, as relying on the exact value of a real number is erroneous, anyway. So a real number never can be considered to *exactly* *be* 1.5, but just somewhere nearby, and hence it's not legal to predict

Re: [fpc-pascal] round(2.5)=2

2018-06-08 Thread Bernd Oppolzer
Am 08.06.2018 um 14:47 schrieb Klaus Hartnegg: Hi, The round function behaves different than in TurboPascal, and its English Wiki page differs from the German page. When given an argument halfway between to integers, FreePascal rounds to the nearest even number, TurboPascal always rounds