float-sup.el 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;;; float-sup.el --- define some constants useful for floating point numbers.
  2. ;; Copyright (C) 1985-1987, 2001-2017 Free Software Foundation, Inc.
  3. ;; Maintainer: emacs-devel@gnu.org
  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. (defconst pi float-pi
  23. "Obsolete since Emacs-23.3. Use `float-pi' instead.")
  24. (internal-make-var-non-special 'pi)
  25. (defconst float-e (exp 1) "The value of e (2.7182818...).")
  26. (defconst degrees-to-radians (/ float-pi 180.0)
  27. "Degrees to radian conversion constant.")
  28. (defconst radians-to-degrees (/ 180.0 float-pi)
  29. "Radian to degree conversion constant.")
  30. ;; These expand to a single multiply by a float when byte compiled.
  31. (defmacro degrees-to-radians (x)
  32. "Convert X from degrees to radians."
  33. (list '* degrees-to-radians x))
  34. (defmacro radians-to-degrees (x)
  35. "Convert X from radians to degrees."
  36. (list '* radians-to-degrees x))
  37. (provide 'lisp-float-type)
  38. ;;; float-sup.el ends here