ttrig.pp 753 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. program ttrig;
  2. {$modeswitch exceptions}
  3. uses
  4. jdk15;
  5. {$macro on}
  6. {$define writeln:=JLSystem.fout.println}
  7. procedure do_error(i : longint);
  8. begin
  9. // writeln('Error near ',i);
  10. raise JLException.create('Error near '+UnicodeString(JLInteger.valueOf(i).toString));
  11. end;
  12. var
  13. s0,s1,s2 : single;
  14. begin
  15. writeln('--- Testing single functions ---');
  16. // 0.0
  17. s0:=0.0;
  18. s1:=sin(s0);
  19. if s1<>0.0 then
  20. do_error(1);
  21. s1:=cos(s0);
  22. if s1<>1.0 then
  23. do_error(2);
  24. s1:=arctan(s0);
  25. if s1<>0.0 then
  26. do_error(3);
  27. // pi/2
  28. s2:=pi/2;
  29. s1:=sin(s2);
  30. if s1<>1.0 then
  31. do_error(100);
  32. s1:=cos(s2);
  33. { with single precision, the result is -4.371138829E-08 }
  34. if abs(s1-0.0)>4.371138829E-08 then
  35. do_error(101);
  36. end.