Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-03

FormatFloat produces strange result based in different data types

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi

When pass 0.005 into the FormatFloat and asking it to format with 2 decimal digits, using different data types (extended, double, single, real), I get different result. Also it is not consistent with Delphi.

I believe this is a bug, but not sure if it has already been address in newer versions of FPC. I am currently using 2.0.2

Free Pascal result:
e: $ 0.00 <==== This is different r: $ 0.01
d: $ 0.01
s: $ 0.00

Delphi result:
e: $ 0.01
r: $ 0.01
d: $ 0.01
s: $ 0.00

The program:

----------------------------------------------------------------
program project1;
{$mode objfpc}{$H+}
uses
 {$IFDEF UNIX}{$IFDEF UseCThreads}
 cthreads,
 {$ENDIF}{$ENDIF}
 Classes
 ,SysUtils;
var
 e: extended;
 r: real;
 d: double;
 s: single;
 result: string;
begin
 e := 0.005;
 r := 0.005;
 d := 0.005;
 s := 0.005;
 result := FormatFloat('$ #,##0.00', e);
 writeln('e: ' + result);
 result := FormatFloat('$ #,##0.00', r);
 writeln('r: ' + result);
 result := FormatFloat('$ #,##0.00', d);
 writeln('d: ' + result);
 result := FormatFloat('$ #,##0.00', s);
 writeln('s: ' + result);
end.
----------------------------------------------------------------

Regards,
- Graeme -

Reply by email

Dr. Karl-Michael Schindler
to Graeme Geldenhuys

Hi,

As told on the irc channel. I have an Intel/iMac, where I could do tests for i386-darwin. But would need some guidance. No direct ssh, though, because of NAT. double tunnel would be a possibility.

Reply by email