float-sup.el 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ;;; float-sup.el --- define some constants useful for floating point numbers.
  2. ;; Copyright (C) 1985-1987, 2001-2012 Free Software Foundation, Inc.
  3. ;; Maintainer: FSF
  4. ;; Keywords: internal
  5. ;; Package: emacs
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;;; Code:
  19. ;; Provide an easy hook to tell if we are running with floats or not.
  20. ;; Define pi and e via math-lib calls (much less prone to killer typos).
  21. (defconst float-pi (* 4 (atan 1)) "The value of Pi (3.1415926...).")
  22. (progn
  23. ;; Simulate a defconst that doesn't declare the variable dynamically bound.
  24. (setq-default pi float-pi)
  25. (put 'pi 'variable-documentation
  26. "Obsolete since Emacs-23.3. Use `float-pi' instead.")
  27. (put 'pi 'risky-local-variable t)
  28. (push 'pi current-load-list))
  29. (defconst float-e (exp 1) "The value of e (2.7182818...).")
  30. (defconst degrees-to-radians (/ float-pi 180.0)
  31. "Degrees to radian conversion constant.")
  32. (defconst radians-to-degrees (/ 180.0 float-pi)
  33. "Radian to degree conversion constant.")
  34. ;; These expand to a single multiply by a float when byte compiled.
  35. (defmacro degrees-to-radians (x)
  36. "Convert X from degrees to radians."
  37. (list '* degrees-to-radians x))
  38. (defmacro radians-to-degrees (x)
  39. "Convert X from radians to degrees."
  40. (list '* radians-to-degrees x))
  41. (provide 'lisp-float-type)
  42. ;;; float-sup.el ends here