PI()

函数说明

PI() 返回数学常量 π (pi)。

函数语法

  1. > PI()

示例

  1. drop table if exists t1;
  2. create table t1(a int,b float);
  3. insert into t1 values(0,0),(-15,-20),(-22,-12.5);
  4. insert into t1 values(0,360),(30,390),(90,450),(180,270),(180,180);
  5. mysql> select acos(a*pi()/180) as acosa,acos(b*pi()/180) acosb from t1;
  6. +--------------------+--------------------+
  7. | acosa | acosb |
  8. +--------------------+--------------------+
  9. | 1.5707963267948966 | 1.5707963267948966 |
  10. | 1.8356824738191324 | 1.927370391646567 |
  11. | 1.9648910192076245 | 1.7907312931992256 |
  12. | 1.5707963267948966 | NULL |
  13. | 1.0197267436954502 | NULL |
  14. | NULL | NULL |
  15. | NULL | NULL |
  16. | NULL | NULL |
  17. +--------------------+--------------------+
  18. 8 rows in set (0.01 sec)
  19. mysql> select acos(a*pi()/180)*acos(b*pi()/180) as acosab,acos(acos(a*pi()/180)) as c from t1;
  20. +--------------------+------+
  21. | acosab | c |
  22. +--------------------+------+
  23. | 2.4674011002723395 | NULL |
  24. | 3.5380400485035204 | NULL |
  25. | 3.518591835821214 | NULL |
  26. | NULL | NULL |
  27. | NULL | NULL |
  28. | NULL | NULL |
  29. | NULL | NULL |
  30. | NULL | NULL |
  31. +--------------------+------+
  32. 8 rows in set (0.01 sec)