Sign in Join

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

Mailing lists / fpc-devel / 2008-04

How to convert Double to Comp without warning

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

Compiling this code:

var
  t: TDateTime;
  m: Comp;
begin
  t := 1000.999;
  m := t;
end.

Throws:
Warning: Automatic type conversion from floating type to COMP which is an integer type

How I can make this conversion without warning?
Overtyping m := Comp(t) is confusing and not delphi compatible.

Thanks.

Petr

Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223 Czech Republic (Eastern Europe) fax: +420 466510709

Reply by email

Unknown author
to Marco van de Voort: FPC is not warning compatible with FPC. Proposed solution looks fine to me.
Marco van de Voort wrote
> How I can make this conversion without warning? > Overtyping m := Comp(t) is confusing and not delphi compatible. FPC is not warning compatible with FPC. Proposed solution looks fine to me.
program co;
uses
  Classes, SysUtils;
var
  t: TDateTime;
  m: Comp;
begin
  t := 1000.999;
  m := Comp(t);
  writeln(m);
end.

#fpc -S2 co.pas
#./co
1.00100000000000E+0003

#fpc -Sd co.pas
#./co
4.65201609613812E+0018

#dcc co.pas
4.65201609613812E+0018

Petr

Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223 Czech Republic (Eastern Europe) fax: +420 466510709

Reply by email