Math.k 757 B

12345678910111213141516171819202122
  1. invoke {
  2. import * from Math
  3. function float_equal (a: Number, b: Number) -> Bool {
  4. return abs(a - b) < 1e-6
  5. }
  6. assert float_equal(E, exp(1))
  7. assert float_equal(PI, atan2(1,1)*4)
  8. assert float_equal(sqrt(2)^2, 2)
  9. assert float_equal(cbrt(-8), -2)
  10. assert float_equal(exp(10), E^10)
  11. assert float_equal(log(exp(10)), 10)
  12. assert float_equal(rad2deg(PI/3), 60)
  13. assert float_equal(PI/3, deg2rad(60))
  14. assert float_equal(sin(PI/3), sqrt(3)/2)
  15. assert float_equal(cos(PI/3), 1/2)
  16. assert float_equal(tan(PI/3), sqrt(3))
  17. assert float_equal(PI/3, asin(sqrt(3)/2))
  18. assert float_equal(PI/3, acos(1/2))
  19. assert float_equal(PI/3, atan(sqrt(3)))
  20. assert float_equal(atan2(sqrt(3), 1), atan(sqrt(3)))
  21. }