home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / modes / multi-forms-mode / utilities / ritter-math.el < prev    next >
Encoding:
Text File  |  1992-06-03  |  1.2 KB  |  58 lines

  1. ;;;; -*- Mode: Emacs-Lisp -*- 
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;;; 
  4. ;;;; File            : ritter-math.el
  5. ;;;; Author          : Frank Ritter
  6. ;;;; Created On      : Fri Dec  6 16:09:31 1991
  7. ;;;; Last Modified By: Frank Ritter
  8. ;;;; Last Modified On: Wed Jun  3 13:40:45 1992
  9. ;;;; Update Count    : 7
  10. ;;;; 
  11. ;;;; PURPOSE
  12. ;;;;     Some simple math extensions to elisp.
  13. ;;;; TABLE OF CONTENTS
  14. ;;;;    I.    log10
  15. ;;;;    II.    signp
  16. ;;;; 
  17. ;;;; Copyright 1991, Carnegie Mellon University.
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19. ;;;; Status          : Unknown, Use with caution!
  20. ;;;; HISTORY
  21. ;;;; 
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23.  
  24. (provide 'ritter-math)
  25.  
  26. (if (fboundp 'proclaim-inline)
  27.   (proclaim-inline
  28.     log10    
  29.     log10plus
  30. ))
  31.  
  32.  
  33. ;;;
  34. ;;;    I.    log10
  35. ;;;
  36.  
  37. (defun log10 (x)
  38.   (if (< x 0) (error "log10 error."))
  39.   (if (> x 1)
  40.       (log10plus x)
  41.     (if (= x 1)
  42.         0
  43.     (log10minus x))))
  44.  
  45. (defun log10plus (x)
  46.   (let ((dividend (/ x 10)))
  47.   (if (not (= 0 dividend))
  48.       (+ 1 (log10plus dividend))
  49.      0)))
  50.  
  51.  
  52. ;;;
  53. ;;;    II.    signp
  54. ;;;
  55.  
  56. (defmacro signp (arg)
  57.   (list 'if (list '> arg 0) 1 -1))
  58.