Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Graeme Geldenhuys
On 5/30/07, Jonas Maebe <[EMAIL PROTECTED]> wrote: 0.005, as extended, is actually 0.00499898356046329484 As double, it is actually 0.0050001 For now I have managed to implement a work-around in my code which passes all unit tests I could throw at it. I first look

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Michael Van Canneyt
On Wed, 30 May 2007, Graeme Geldenhuys wrote: > On 5/30/07, Yury Sidorov <[EMAIL PROTECTED]> wrote: > > > Yeah, that outputs the correct value here as well. Confirmed a bug > > > then! > > > > Currency to string conversion is handled in other way that float > > types. In original example extend

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Jonas Maebe
On 30 mei 2007, at 15:08, Graeme Geldenhuys wrote: Yury, you are right! I never spotted that, thanks. Running the example program below shows the difference in output. The currency type rounds to 0.01 and the extended type rounds to 0.00. Either way, I still believe this is a bug in FormatFlo

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Graeme Geldenhuys
On 5/30/07, Yury Sidorov <[EMAIL PROTECTED]> wrote: > Yeah, that outputs the correct value here as well. Confirmed a bug > then! Currency to string conversion is handled in other way that float types. In original example extended type was used Yury, you are right! I never spotted that,

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Yury Sidorov
From: "Graeme Geldenhuys" <[EMAIL PROTECTED]> On 5/30/07, Jonas Maebe <[EMAIL PROTECTED]> wrote: var c: currency; begin c:=0.005; writeln(c:0:2); end. writes 0.01. So it's probably a bug in one of the umpteen sysutils float formatting "helpers" (and if someone fixes it, please take i

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Graeme Geldenhuys
On 5/30/07, Jonas Maebe <[EMAIL PROTECTED]> wrote: var c: currency; begin c:=0.005; writeln(c:0:2); end. writes 0.01. So it's probably a bug in one of the umpteen sysutils float formatting "helpers" (and if someone fixes it, please take into Yeah, that outputs the correct value here

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Graeme Geldenhuys
On 5/30/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote: And that's all that can be found. So from this I conclude it's up to the CPU, and furthermore you cannot assume anything about it since the behaviour of the CPU is programmable with the abovementioned procedures. (which are obviously not

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Jonas Maebe
On 30 mei 2007, at 11:56, Michael Van Canneyt wrote: On Wed, 30 May 2007, Jonas Maebe wrote: The writing of floating point values does not use the rounding functionality provided by the FPU, it is implemented in a completely cpu- independent way. Doesn't it use rounding ? It does, but d

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Michael Van Canneyt
On Wed, 30 May 2007, Jonas Maebe wrote: > > On 30 mei 2007, at 11:10, Michael Van Canneyt wrote: > > >Not that I know of. As far as I know, it's left up to the CPU. > >But it's been a long time since I looked at this, so I might > >be wrong. > > The writing of floating point values does not u

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Jonas Maebe
On 30 mei 2007, at 11:10, Michael Van Canneyt wrote: Not that I know of. As far as I know, it's left up to the CPU. But it's been a long time since I looked at this, so I might be wrong. The writing of floating point values does not use the rounding functionality provided by the FPU, it is

Re: [fpc-devel] FormatFloat bug

2007-05-30 Thread Michael Van Canneyt
On Wed, 30 May 2007, Graeme Geldenhuys wrote: > On 5/29/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote: > > If I remember correctly: > > Bookkeepers rounding as implemented by the Intel processors. > > No own routines are used. It's left up to the processor. > > > I thought FormatFloat() us

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Graeme Geldenhuys
On 5/29/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote: If I remember correctly: Bookkeepers rounding as implemented by the Intel processors. No own routines are used. It's left up to the processor. I thought FormatFloat() uses Common Rounding and FormatCurr() uses Bankers Rounding. This w

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Burkhard Carstens
Am Dienstag, 29. Mai 2007 20:51 schrieb Graeme Geldenhuys: > On 5/29/07, Joao Morais <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > Attached is a application that demonstrates a bug in FormatFloat. > > > All tests pass when run under Delphi, but test four fails under > > > Free Pascal. > > > > I

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Michael Van Canneyt
On Tue, 29 May 2007, Graeme Geldenhuys wrote: > On 5/29/07, Joao Morais <[EMAIL PROTECTED]> wrote: > > Graeme Geldenhuys wrote: > > > > > Hi, > > > > > > Attached is a application that demonstrates a bug in FormatFloat. All > > > tests pass when run under Delphi, but test four fails under Free

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Graeme Geldenhuys
On 5/29/07, Joao Morais <[EMAIL PROTECTED]> wrote: > Hi, > > Attached is a application that demonstrates a bug in FormatFloat. All > tests pass when run under Delphi, but test four fails under Free > Pascal. IMHO, fpc behaves correctly. 0.005 is closer than 0 instead 0.01. If you try 0.0050

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Graeme Geldenhuys
On 5/29/07, Joao Morais <[EMAIL PROTECTED]> wrote: Graeme Geldenhuys wrote: > Hi, > > Attached is a application that demonstrates a bug in FormatFloat. All > tests pass when run under Delphi, but test four fails under Free > Pascal. IMHO, fpc behaves correctly. 0.005 is closer than 0 instead 0

Re: [fpc-devel] FormatFloat bug

2007-05-29 Thread Joao Morais
Graeme Geldenhuys wrote: Hi, Attached is a application that demonstrates a bug in FormatFloat. All tests pass when run under Delphi, but test four fails under Free Pascal. IMHO, fpc behaves correctly. 0.005 is closer than 0 instead 0.01. If you try 0.0050001, you will have 0.01, also co

[fpc-devel] FormatFloat bug

2007-05-29 Thread Graeme Geldenhuys
Hi, Attached is a application that demonstrates a bug in FormatFloat. All tests pass when run under Delphi, but test four fails under Free Pascal. Here is the application output: --- $ ./project1 Time:00.001 N:7 E:0 F:1 I:0 TTestFormatFloat Time:00.001