stdmathlib.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. .. _stdlib_stdmathlib:
  2. ================
  3. The Math library
  4. ================
  5. the math lib provides basic mathematic routines. The library mimics the
  6. C runtime library implementation.
  7. ------------
  8. Squirrel API
  9. ------------
  10. +++++++++++++++
  11. Global Symbols
  12. +++++++++++++++
  13. .. js:function:: abs(x)
  14. returns the absolute value of `x` as an integer
  15. .. js:function:: acos(x)
  16. returns the arccosine of `x`
  17. .. js:function:: asin(x)
  18. returns the arcsine of `x`
  19. .. js:function:: atan(x)
  20. returns the arctangent of `x`
  21. .. js:function:: atan2(x,y)
  22. returns the arctangent of `x/y`
  23. .. js:function:: ceil(x)
  24. returns a float value representing the smallest integer that is greater than or equal to `x`
  25. .. js:function:: cos(x)
  26. returns the cosine of `x`
  27. .. js:function:: exp(x)
  28. returns the exponential value of the float parameter `x`
  29. .. js:function:: fabs(x)
  30. returns the absolute value of `x` as a float
  31. .. js:function:: floor(x)
  32. returns a float value representing the largest integer that is less than or equal to `x`
  33. .. js:function:: log(x)
  34. returns the natural logarithm of `x`
  35. .. js:function:: log10(x)
  36. returns the logarithm base-10 of `x`
  37. .. js:function:: pow(x,y)
  38. returns `x` raised to the power of `y`
  39. .. js:function:: rand()
  40. returns a pseudorandom integer in the range 0 to `RAND_MAX`
  41. .. js:function:: sin(x)
  42. rreturns the sine of `x`
  43. .. js:function:: sqrt(x)
  44. returns the square root of `x`
  45. .. js:function:: srand(seed)
  46. sets the starting point for generating a series of pseudorandom integers
  47. .. js:function:: tan(x)
  48. returns the tangent of `x`
  49. .. js:data:: RAND_MAX
  50. the maximum value that can be returned by the `rand()` function
  51. .. js:data:: PI
  52. The numeric constant pi (3.141592) is the ratio of the circumference of a circle to its diameter
  53. ------------
  54. C API
  55. ------------
  56. .. _sqstd_register_mathlib:
  57. .. c:function:: SQRESULT sqstd_register_mathlib(HSQUIRRELVM v)
  58. :param HSQUIRRELVM v: the target VM
  59. :returns: an SQRESULT
  60. :remarks: The function aspects a table on top of the stack where to register the global library functions.
  61. initializes and register the math library in the given VM.