ttrig.pas 563 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. procedure do_error(i : longint);
  2. begin
  3. writeln('Error near ',i);
  4. halt(1);
  5. end;
  6. var
  7. s0,s1,s2 : single;
  8. begin
  9. writeln('--- Testing single functions ---');
  10. // 0.0
  11. s0:=0.0;
  12. s1:=sin(s0);
  13. if s1<>0.0 then
  14. do_error(1);
  15. s1:=cos(s0);
  16. if s1<>1.0 then
  17. do_error(2);
  18. s1:=arctan(s0);
  19. if s1<>0.0 then
  20. do_error(3);
  21. // pi/2
  22. s2:=pi/2;
  23. s1:=sin(s2);
  24. if s1<>1.0 then
  25. do_error(100);
  26. s1:=cos(s2);
  27. { with single precision, the result is -4.371138829E-08 }
  28. if abs(s1-0.0)>4.371138829E-08 then
  29. do_error(101);
  30. end.