testfpuc.pp 783 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. { %target=linux,freebsd,darwin,solaris }
  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. end;
  27. end;
  28. procedure DoTest;
  29. begin
  30. With TTest.Create(720) do
  31. Free;
  32. end;
  33. begin
  34. DoTest;
  35. end.