[fpc-devel] FormatFloat bug

Graeme Geldenhuys graemeg.lists at gmail.com
Wed May 30 15:08:11 CEST 2007


On 5/30/07, Yury Sidorov <jura at cp-lab.com> 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, 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 FormatFloat.

Test system is a Intel Pentium 4 processor running Windows 2000 and Linux.

-----------------------------------------------------------
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { add your units here };

var
  c: currency;
  e: extended;

begin
  c:=0.005;
  e:= 0.005;
  writeln(c:0:2);
  writeln(e:0:2);
end.
-----------------------------------------------------------


-- 
Graeme Geldenhuys
General error, hit any user to continue.



More information about the fpc-devel mailing list