testfpuc.pp 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. { %target=linux,freebsd,darwin,solaris,aix,android,haiku }
  2. {$mode objfpc}
  3. program testr;
  4. uses sysutils;
  5. function sprintf(buf,fmt : pchar) : longint; varargs;cdecl; external 'c';
  6. {$ifdef haiku}
  7. function cosh(f : double) : double; cdecl; external 'root';
  8. function ccos(f : double) : double; cdecl; external 'root' name 'cos';
  9. {$else}
  10. function cosh(f : double) : double; cdecl; external 'm';
  11. function ccos(f : double) : double; cdecl; external 'm' name 'cos';
  12. {$endif}
  13. Type
  14. TTest = Class(TObject)
  15. Constructor Create(Max : Integer);
  16. end;
  17. Constructor TTest.Create(Max : Integer);
  18. Var
  19. I,J : integer;
  20. F : single;
  21. buf : ansistring;
  22. begin
  23. For I:=1 to Max do
  24. begin
  25. F:=ccos(I/180*pi);
  26. setlength(buf,100);
  27. setlength(buf,sprintf(pchar(buf),'%d: f: %f and round f*10: ',i,f));
  28. f:=f*10.0;
  29. f:=cosh(f);
  30. writeln(buf,round(F));
  31. end;
  32. end;
  33. procedure DoTest;
  34. begin
  35. With TTest.Create(720) do
  36. Free;
  37. end;
  38. begin
  39. DoTest;
  40. end.