[ Skill ] 中如何获取内置的数学常量?

https://www.cnblogs.com/yeungchie/

  • code
defMathConstants(s_id)
  • describe
  1. s_id 类型为 symbol
  2. 通过 s_id.Name 获取目标常量。
Name Meaning
E The base of natural logarithms. (e)
LOG2E The base-2 logarithm of e
LOG10E The base-10 logarithm of e
LN2 The natural logarithm of 2.
LN10 The natural logarithm of 10.
PI The ratio of the circumference of a circle to its diameter.(π)
PI_OVER_2 π / 2
PI_OVER_4 π / 4
ONE_OVER_PI 1 / π
TWO_OVER_PI 2 / π
TWO_OVER_SQRTPI
SQRT_TWO (The positive square root of 2.)
SQRT_POINT_FIVE (The positive square root of 1/2.)
INT_MAX The maximum value of a SKILL integer.
INT_MIN The minimum value of a SKILL integer.
DBL_MAX The maximum value of a SKILL double.
DBL_MIN The minimum value of a SKILL double.
SHRT_MAX The maximum value of a SKILL "short" integer.
SHRT_MIN The minimum value of a SKILL "short" integer.

The minimum value of a SKILL integer is -2147483648.
The minimum literal value which may appear in a program is -2147483647.

  • example
; 获取 π
defMathConstants('ycMath)
printf("%f\n" ycMath.PI)

=>3.141593
=>t
posted @ 2020-08-02 20:19  YEUNGCHIE  阅读(689)  评论(0编辑  收藏  举报