tw2129.pp 932 B

12345678910111213141516171819202122232425262728293031323334
  1. { %version=1.1 }
  2. { %fail }
  3. { Source provided for Free Pascal Bug Report 2129 }
  4. { Submitted by "Bill Rayer" on 2002-09-18 }
  5. { e-mail: [email protected] }
  6. {$mode delphi}
  7. (*
  8. Comp() cast has different effect in FPC.
  9. Compiles using Delphi4:
  10. dcc32 -CC fpc19
  11. Compiles in FPC 1.0.6:
  12. ppc386 -WC fpc19
  13. When run, the Delphi version shows -6.5E+18, but the FPC version
  14. shows zero. In Delphi, the comp() cast actually moves 8 bytes from
  15. the double into the comp without converting the data, but FPC uses
  16. floating point instructions to convert the data and therefore prints
  17. zero.
  18. In Delphi, if you want to convert a double to a float, you just use
  19. the assignment "comp1 := dbl1" which corresponds to the FLD/FIST
  20. opcodes. FPC should not use the comp() cast for doing this, since
  21. it introduces a subtle incompatibility with Delphi.
  22. *)
  23. program fpc19;
  24. var
  25. single1 : single;
  26. dbl1 : double;
  27. begin
  28. single1 := single(dbl1);
  29. end.