testfpuc.pp 784 B

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