home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / patches / float-sup.patch < prev    next >
Encoding:
Internet Message Format  |  1991-08-22  |  80.1 KB

  1. Path: dg-rtp!rock!mcnc!gatech!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!ucbvax!bloom-beacon!eru!kth.se!news
  2. From: bg@bg.nada.kth.se (Bjorn Gronvall)
  3. Newsgroups: gnu.emacs.sources
  4. Subject: Floting-point numbers in emacs
  5. Date: 13 Aug 91 13:12:47 GMT
  6. Organization: Royal Institute of Technology, Stockholm, Sweden
  7.  
  8. ;; LCD Archive Entry:
  9. ;; float-sup.patch
  10. ;; |Wolfgang Rupprecht, Bjorn Gronvall|wolfgang@mgm.mit.edu, bg@bg.nada.kth.se
  11. ;; |True floating point lisp data type for Emacs 18.57 (source code patch)
  12. ;; |91-08-13||~/patches/float-sup.patch.Z|
  13.  
  14.  
  15. Yes, I know that programmers don't use flotingpoint
  16. but some of our users does. Therfore I have updated
  17. Wolfgang Rupprecht patch to work with emacs-18.57.
  18.  
  19. To install this patch follow the following steps:
  20.  
  21. 1)
  22. Run patch (on file included below).
  23.  
  24. 2)
  25. cp lisp/float-sup.el lisp/float-sup.elc
  26. This is for bootstrapping, your old emacs
  27. can't compile this beast (yet).
  28.  
  29. 3)
  30. byte-recompile-directory lisp (using emacs)
  31.  
  32. 4)
  33. Add LISP_FLOAT_TYPE to your src/config.h.
  34. You will also need to increase the value
  35. of PURESIZE by roughly 5000.
  36.  
  37. 5)
  38. Run make
  39.  
  40. 6)
  41. byte-compile lisp/float-sup.el
  42.  
  43. 7)
  44. Run make again (to complete bootstrap process).
  45.  
  46. and your hopfully done.
  47.  
  48.     Cheers
  49.     Bjvrn
  50.  
  51. Only in emacs: FLONUM
  52. *** emacs-18.57/FLONUM    Tue Aug 13 14:06:45 1991
  53. --- emacs/FLONUM    Tue Aug 13 10:50:22 1991
  54. ***************
  55. *** 0 ****
  56. --- 1,263 ----
  57. + ###############################################################################
  58. + ##                                         ##
  59. + ##    File:     FLONUMS                             ##
  60. + ##    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ##
  61. + ##    Created:  Tue Oct 27 15:58:53 EST 1987                     ##
  62. + ##    Contents: Documentation File for GnuEmacs with floats             ##
  63. + ##                                         ##
  64. + ##    Copyright (c) 1987 Wolfgang Rupprecht.                     ##
  65. + ##    All rights reserved.                             ##
  66. + ##                                         ##
  67. + ##    $Log$                                     ##
  68. + ###############################################################################
  69. + INTRO
  70. + I have added a true floating point data type (flonum in lisp jargon)
  71. + to the lisp interpreter of GnuEmacs.  This allows one to do emacs-lisp
  72. + calculations using floating point numbers as well as integers.  In
  73. + addition, GnuEmacs now has hooks to call all of the common
  74. + trigonometric functions from lisp.  One may now, for example, use the
  75. + *scratch* buffer as a real scientific calculator (programable even!!).
  76. + It is not that hard to write a super spreadsheet calculator in elisp,
  77. + using this package.
  78. + NEW FEATURES
  79. + The basic features features provided are:
  80. + *    a lisp float data type, that uses the C type "double" for it's
  81. +     basic storage
  82. + *    upgrading of the built-in math subroutines to allow manipulation
  83. +     of floats
  84. + *    conversion routines to convert to and from floats and ints
  85. + *    predicates for testing if a number is a float, float-or-int,
  86. +     or float-or-int-or-marker
  87. + *    trig math routines. (sin, cos, tan, exponentials, logs, bessels, etc.)
  88. + *    upgrading of int-to-string, string-to-int, and the basic printing
  89. +     and reading routines to allow float reading/printing.
  90. + *    changes to garbage-collect to also collect old floats.
  91. + The lisp reader will interpret strings of one of the following three
  92. + forms as a float:
  93. +      <number>.<number>
  94. +      <number>e<number>
  95. +      <number>.<number>e<number>
  96. + The mantissa and the exponent may both have a single + or - sign
  97. + prefixed.  All other strings are treated as symbols.  This is
  98. + intentional, and meant to prevent numbers and dotted pairs of 
  99. + ints from looking too much like one another. 
  100. +      legal numbers:
  101. +       (0 . 1)      a doted pair of integers 0 and 1
  102. +       (0.1)        a list of one float with value 1/10
  103. +       0.0        the floating pt. zero
  104. +       1.0        the floating point one
  105. +       1e0        also floating pt. one
  106. +       0e0        also floating pt. zero
  107. +          (0. 1)        a list of symbol "0\." and integer 0
  108. +      (0 .1)        a list of integer 0 and symbol "\.1"
  109. +           0.        symbol "0\."
  110. +       .1        symbol "\.1"
  111. + The built in math functions promote the type of the calculation from
  112. + integer to float at the first encounter with a float.
  113. +     (+ 1 2 3 4 5 6.0 7 8 9)
  114. + The above expression will be done in integer math for the addition of
  115. + 1, 2, 3, 4 and 5.  The rest of the calculation is done in floating
  116. + point math with the result being a float.  This allows an integer 
  117. + calculation to still return an integer.  To force a floating point
  118. + calculation, convert the first argument to a float.
  119. + Ints can be converted to floats by using the function "float".
  120. + Floats can be converted to ints by one of several functions, 
  121. + depending on the type of rounding desired.
  122. +        round        returns the closest integer
  123. +        ceiling        returns the largest integer that is not larger 
  124. +             than the arg (round towards -infinity)
  125. +        floor        returns the smallest integer that is not smaller
  126. +             than the arg (round towards +infinity)
  127. +        truncate        returns the integer corresponding to the mantissa
  128. +             of the float. (round towards zero)
  129. + On most machines that gnuemacs runs on, lisp integers are only 24 bits
  130. + long.  One must be careful when convering large floats to integers that
  131. + one doesn't exceed the storage capacity of integers.  Integers (of 24
  132. + bit size) can only have a range of slightly over +/- 8 million.  The
  133. + same caution applies when performing mathematical operations on
  134. + integers.  If you need to work with large numbers, it's safest to use 
  135. + floats.
  136. + The math trig functions sin/cos/tan all take their arguments in
  137. + radians.  Values can be converted to the desired radix with the
  138. + functions degrees-to-radians and radians-to-degrees.
  139. + Some of the new functions (or functions with new args/return values):
  140. + abs acosh asin asinh atan atanh ceiling cos cosh cube-root erf erfc
  141. + exp expm1 expt fceiling ffloor float floor fround ftruncate
  142. + garbage-collect int-to-string integer-or-float-or-marker-p
  143. + integer-or-floatp j0 j1 jn log log-gamma log10 log1p round sin sinh
  144. + sqrt tan tanh truncate y0 y1 yn
  145. + The full documentations for these functions is on-line under C-h f
  146. + <function-name> and at the end of this document. 
  147. + The lisp variable float-output-format controls the printed
  148. + representation of floats.  The available print formats are:
  149. +        <number>.<number>         with a 'd' specifier
  150. +        <number>.<number>e<number>    with an 'e' specifier
  151. +        (or data dependent switching 
  152. +         between the above two)         with no letter specifier
  153. + The field width may be contolled by an optional numeric field
  154. + preceeding the above format specifier. 
  155. + MAKING FLOAT-EMACS:
  156. + To make emacs with flonums (ie. lisp floats) define LISP_FLOAT_TYPE in
  157. + your conf.h file.  The resultant emacs will be less than 6% larger.
  158. + This has been tested on a Vax-750 running BSD 4.3.
  159. +     text    data    bss    dec    hex
  160. +     369664    180224    0    549888    86400    emacs-18.49
  161. +     391168    187392    0    578560    8d400    float-emacs-18.49
  162. + PORTING to other machines:
  163. + If you aren't running with a BSD/vax style printf, you may no be able
  164. + to use the optional runtime selectable floating point print-width stuff.
  165. + (I'll probably fix this soon.)
  166. + If you don't have some of the math-lib functions that emacs wants
  167. + linked in, don't worry.  These are all entirely optional.  Just #ifdef
  168. + the math routines out, stub them up, or find a copy of the 4.3 BSD
  169. + routines. (Check the 4.3 BSD math(3) man page for details on copying
  170. + the math-lib routines.)
  171. + Appendix A: floating pt. docstrings
  172. + abs
  173. +    Function: Return the absolute value of ARG.
  174. + acosh
  175. +    Function: Return the inverse hyperbolic cosine of ARG.
  176. + asin
  177. +    Function: Return the inverse sine of ARG.
  178. + asinh
  179. +    Function: Return the inverse hyperbolic sine of ARG.
  180. + atan
  181. +    Function: Return the inverse tangent of ARG.
  182. + atanh
  183. +    Function: Return the inverse hyperbolic tangent of ARG.
  184. + ceiling
  185. +    Function: Return the smallest integer no less than ARG. (round toward +inf)
  186. + cos
  187. +    Function: Return the cosine of ARG.
  188. + cosh
  189. +    Function: Return the hyperbolic cosine of ARG.
  190. + cube-root
  191. +    Function: Return the cube root of ARG.
  192. + erf
  193. +    Function: Return the mathematical error function of ARG.
  194. + erfc
  195. +    Function: Return the complementary error function of ARG.
  196. + exp
  197. +    Function: Return the exponential base e of ARG.
  198. + expm1
  199. +    Function: Return the exp(x)-1 of ARG.
  200. + expt
  201. +    Function: Return the exponential x ** y.
  202. + fceiling
  203. +    Function: Return the smallest integral floating pt. number no less than ARG.
  204. +    (round towards +inf)
  205. + ffloor
  206. +    Function: Return the largest floating pt number no greater than ARG.
  207. +    (round towards -inf)
  208. + float
  209. +    Function: Return the floating pt. number equal to ARG.
  210. + floatp
  211. +    Function: T if OBJECT is a floating pt. number.
  212. + float-output-format
  213. +    Variable: The format descriptor string (or nil) that lisp uses to print out
  214. +    floats.  Nil means use built-in defaults.
  215. +    The descriptor string consists of an optional field-width spec,
  216. +    followed by an optional output-style descriptor.
  217. +    
  218. +    Valid field-widths specs are:
  219. +    The empty string for default precision.
  220. +    0-20 for exponential notation, or 1-20 for decimal point notation.  A 0
  221. +    field spec causes the printing of the decimal point to be supressed.
  222. +    Using an out of bounds specs cause the closest valid spec to be used.
  223. +    
  224. +    Valid ouput-styles may be one of the following:
  225. +    The letter 'e' for exponential notation "<number>.<number>e<number>"
  226. +    The letter 'd' for decimal point notation "<number>.<number>".
  227. +    The empty string, for the defaulted output style.  This may print in
  228. +    either format in a data-dependent manner, choosing whatever produces
  229. +    the shortest string.
  230. +    
  231. + floor
  232. +    Function: Return the largest integer no greater than ARG. (round towards -inf)
  233. + fround
  234. +    Function: Return the nearest integral floating pt. number to ARG.
  235. + ftruncate
  236. +    Function: Truncate a floating point number, returns a float.
  237. +    (Truncates towards zero.) Will fail for floats > max integer.
  238. + garbage-collect
  239. +    Function: Reclaim storage for Lisp objects no longer needed.
  240. +    Returns info on amount of space in use:
  241. +     ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)
  242. +      (USED-MARKERS . FREE-MARKERS) (USED-FLOATS . FREE-FLOATS) 
  243. +      USED-STRING-CHARS USED-VECTOR-SLOTS)
  244. +    Garbage collection happens automatically if you cons more than
  245. +    gc-cons-threshold  bytes of Lisp data since previous garbage collection.
  246. + int-to-string
  247. +    Function: Convert INT to a string by printing it in decimal, with minus sign if negative.
  248. + integer-or-float-or-marker-p
  249. +    Function: T if OBJECT is a floating pointt, normal number, or marker.
  250. + integer-or-floatp
  251. +    Function: T if OBJECT is a floating pt. or normal number.
  252. + j0
  253. +    Function: Return the bessel function j0 of ARG.
  254. + j1
  255. +    Function: Return the bessel function j1 of ARG.
  256. + jn
  257. +    Function: Return the bessel function jN of ARG.
  258. + log
  259. +    Function: Return the natural logarithm of ARG.
  260. + log-gamma
  261. +    Function: Return the log gamma of ARG.
  262. + log10
  263. +    Function: Return the logarithm base 10 of ARG.
  264. + log1p
  265. +    Function: Return the log(1+x) of ARG.
  266. + round
  267. +    Function: Return the nearest integer to ARG.
  268. + sin
  269. +    Function: Return the sine of ARG.
  270. + sinh
  271. +    Function: Return the hyperbolic sine of ARG.
  272. + sqrt
  273. +    Function: Return the square root of ARG.
  274. + tan
  275. +    Function: Return the tangent of ARG.
  276. + tanh
  277. +    Function: Return the hyperbolic tangent of ARG.
  278. + truncate
  279. +    Function: Truncate a floating point number to an int.
  280. +    (Truncates toward zero.)
  281. + y0
  282. +    Function: Return the bessel function y0 of ARG.
  283. + y1
  284. +    Function: Return the bessel function y1 of ARG.
  285. + yn
  286. +    Function: Return the bessel function yN of ARG.
  287.  
  288. *** emacs-18.57/lisp/float-sup.el    Tue Aug 13 14:18:46 1991
  289. --- emacs/lisp/float-sup.el    Tue Aug 13 10:52:38 1991
  290. ***************
  291. *** 0 ****
  292. --- 1,81 ----
  293. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  294. + ;;                                         ;;
  295. + ;;    File:     float-sup.el                             ;;
  296. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  297. + ;;    Created:  Mon Oct 26 09:12:18 EST 1987                     ;;
  298. + ;;    Contents: Flonum support routines and useful constants.             ;;
  299. + ;;          This file is just the tip of the of the iceberg, as        ;;
  300. + ;;          most of the flonum stuff is in the C code.                  ;;
  301. + ;;                                         ;;
  302. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  303. + ;;    All rights reserved.                             ;;
  304. + ;;                                         ;;
  305. + ;;    $Log$                                     ;;
  306. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  307. + ;; GNU Emacs and this file "float-sup.el", is distributed in the hope
  308. + ;; that it will be useful, but WITHOUT ANY WARRANTY.  No author or
  309. + ;; distributor accepts responsibility to anyone for the consequences of
  310. + ;; using it or for whether it serves any particular purpose or works at
  311. + ;; all, unless he says so in writing.  Refer to the GNU Emacs General
  312. + ;; Public License for full details.
  313. + ;; Everyone is granted permission to copy, modify and redistribute GNU
  314. + ;; Emacs and float-sup.el, but only under the conditions described in the
  315. + ;; GNU Emacs General Public License.  A copy of this license is supposed
  316. + ;; to have been given to you along with GNU Emacs so you can know your
  317. + ;; rights and responsibilities.  It should be in a file named COPYING.
  318. + ;; Among other things, the copyright notice and this notice must be
  319. + ;; preserved on all copies.
  320. + ;; If you like my floating point hack, and would like other custom
  321. + ;; (non-proprietary) GnuEmacs extensions, let me know. I may be
  322. + ;; interested in doing it for you on a contract basis. -wsr
  323. + ;; Provide a meaningful error message if we are running on
  324. + ;; bare (non-float) emacs.
  325. + ;; Can't test for 'floatp since that may be defined by float-imitation
  326. + ;; packages like float.el in this very directory.
  327. + (if (fboundp 'integer-or-floatp)
  328. +     nil
  329. +   (error
  330. +     "Can't load float-sup. You aren't running GnuEmacs with the Lisp_Float data type."))
  331. + ;; provide an easy hook to tell if we are running with floats or not.
  332. + (provide 'lisp-float-type)
  333. + ;; define pi and e via math-lib calls. (much less prone to killer typos.)
  334. + (defconst pi (* 4 (atan 1)) "The value of Pi (3.1415926...)")
  335. + (defconst e (exp 1) "The value of e (2.7182818...)")
  336. + ;; Careful when editing this file ... typos here will be hard to spot.
  337. + ;; (defconst pi       3.14159265358979323846264338327
  338. + ;;  "The value of Pi (3.14159265358979323846264338327...)")
  339. + (defconst degrees-to-radians (/ pi 180.0)
  340. +   "Degrees to radian conversion constant")
  341. + (defconst radians-to-degrees (/ 180.0 pi)
  342. +   "Radian to degree conversion constant")
  343. + ;; these expand to a single multiply by a float
  344. + ;; when byte compiled
  345. + (defmacro degrees-to-radians (x)
  346. +   "Convert ARG from degrees to radians."
  347. +   (list '* (/ pi 180.0) x))
  348. + (defmacro radians-to-degrees (x)
  349. +   "Convert ARG from radians to degrees."
  350. +   (list '* (/ 180.0 pi) x))
  351. + ;; some readability macros.
  352. + ;; will eval arg several times,
  353. + ;; but is that a problem?
  354. + (defmacro squared (x)
  355. +   "Return the square of ARG."
  356. +   (list '* x x))
  357. + (defmacro cubed (x)
  358. +   "Return the cube of ARG."
  359. +   (list '* x x x))
  360. diff -rc emacs-18.57/lisp/bytecomp.el emacs/lisp/bytecomp.el
  361. *** emacs-18.57/lisp/bytecomp.el    Wed Jan  9 22:56:32 1991
  362. --- emacs/lisp/bytecomp.el    Tue Aug 13 10:52:38 1991
  363. ***************
  364. *** 1,3 ****
  365. --- 1,15 ----
  366. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  367. + ;;                                         ;;
  368. + ;;    File:     bytecomp.el                             ;;
  369. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  370. + ;;    Created:  Thu Nov  5 15:06:50 EST 1987                     ;;
  371. + ;;    Contents: Gnu bytecomp file, with changes for lisp floats         ;;
  372. + ;;                                         ;;
  373. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  374. + ;;    All rights reserved.                             ;;
  375. + ;;                                         ;;
  376. + ;;    $Log$                                     ;;
  377. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  378.   ;; Compilation of Lisp code into byte code.
  379.   ;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
  380.   
  381. ***************
  382. *** 220,233 ****
  383.         (set-buffer outbuffer)
  384.         (emacs-lisp-mode)
  385.         (erase-buffer)
  386. !       (while (save-excursion
  387. !            (set-buffer inbuffer)
  388. !            (while (progn (skip-chars-forward " \t\n\^l")
  389. !                  (looking-at ";"))
  390. !          (forward-line 1))
  391. !            (not (eobp)))
  392. !     (setq sexp (read inbuffer))
  393. !     (print (byte-compile-file-form sexp) outbuffer))
  394.         (set-buffer outbuffer)
  395.         (goto-char 1)
  396.         ;; In each defun or autoload, if there is a doc string,
  397. --- 232,247 ----
  398.         (set-buffer outbuffer)
  399.         (emacs-lisp-mode)
  400.         (erase-buffer)
  401. ! ;; don't let floats get truncated in the process of printing them.
  402. !       (let ((float-output-format "20e"))
  403. !     (while (save-excursion
  404. !          (set-buffer inbuffer)
  405. !          (while (progn (skip-chars-forward " \t\n\^l")
  406. !                    (looking-at ";"))
  407. !            (forward-line 1))
  408. !          (not (eobp)))
  409. !       (setq sexp (read inbuffer))
  410. !       (print (byte-compile-file-form sexp) outbuffer)))
  411.         (set-buffer outbuffer)
  412.         (goto-char 1)
  413.         ;; In each defun or autoload, if there is a doc string,
  414. Only in emacs/lisp: float-sup.el
  415. diff -rc emacs-18.57/lisp/lisp-mode.el emacs/lisp/lisp-mode.el
  416. *** emacs-18.57/lisp/lisp-mode.el    Wed Jan  9 23:01:19 1991
  417. --- emacs/lisp/lisp-mode.el    Tue Aug 13 10:52:55 1991
  418. ***************
  419. *** 1,3 ****
  420. --- 1,15 ----
  421. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  422. + ;;                                         ;;
  423. + ;;    File:     lisp-mode.el                             ;;
  424. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  425. + ;;    Created:  Thu Nov  5 23:36:37 EST 1987                     ;;
  426. + ;;    Contents: GNU lisp-mode file, with my changes for float support         ;;
  427. + ;;                                         ;;
  428. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  429. + ;;    All rights reserved.                             ;;
  430. + ;;                                         ;;
  431. + ;;    $Log$                                     ;;
  432. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  433.   ;; Lisp mode, and its idiosyncratic commands.
  434.   ;; Copyright (C) 1985 Free Software Foundation, Inc.
  435.   
  436. ***************
  437. *** 48,54 ****
  438.         (modify-syntax-entry ?` "'   " emacs-lisp-mode-syntax-table)
  439.         (modify-syntax-entry ?' "'   " emacs-lisp-mode-syntax-table)
  440.         (modify-syntax-entry ?, "'   " emacs-lisp-mode-syntax-table)
  441. !       (modify-syntax-entry ?. "'   " emacs-lisp-mode-syntax-table)
  442.         (modify-syntax-entry ?# "'   " emacs-lisp-mode-syntax-table)
  443.         (modify-syntax-entry ?\" "\"    " emacs-lisp-mode-syntax-table)
  444.         (modify-syntax-entry ?\\ "\\   " emacs-lisp-mode-syntax-table)
  445. --- 60,72 ----
  446.         (modify-syntax-entry ?` "'   " emacs-lisp-mode-syntax-table)
  447.         (modify-syntax-entry ?' "'   " emacs-lisp-mode-syntax-table)
  448.         (modify-syntax-entry ?, "'   " emacs-lisp-mode-syntax-table)
  449. !       ;; This needs to be changed for the float stuff.
  450. !       ;; I don't want to conditionalize this since it should
  451. !       ;; work the same way if floats are present or not. -wsr
  452. !       ;; (modify-syntax-entry ?. "'   " lisp-mode-syntax-table)
  453. !       (modify-syntax-entry ?. "_   " lisp-mode-syntax-table)
  454.         (modify-syntax-entry ?# "'   " emacs-lisp-mode-syntax-table)
  455.         (modify-syntax-entry ?\" "\"    " emacs-lisp-mode-syntax-table)
  456.         (modify-syntax-entry ?\\ "\\   " emacs-lisp-mode-syntax-table)
  457. diff -rc emacs-18.57/lisp/loadup.el emacs/lisp/loadup.el
  458. *** emacs-18.57/lisp/loadup.el    Wed Jan  9 23:01:30 1991
  459. --- emacs/lisp/loadup.el    Tue Aug 13 10:53:01 1991
  460. ***************
  461. *** 1,3 ****
  462. --- 1,15 ----
  463. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  464. + ;;                                         ;;
  465. + ;;    File:     loadup.el                             ;;
  466. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  467. + ;;    Created:  Thu Nov  5 11:44:26 EST 1987                     ;;
  468. + ;;    Contents: GNU loadup file, with my float code                 ;;
  469. + ;;                                         ;;
  470. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  471. + ;;    All rights reserved.                             ;;
  472. + ;;                                         ;;
  473. + ;;    $Log$                                     ;;
  474. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  475.   ;Load up standardly loaded Lisp files for Emacs.
  476.   ;; This is loaded into a bare Emacs to make a dumpable one.
  477.   ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  478. ***************
  479. *** 62,67 ****
  480. --- 74,84 ----
  481.       (progn
  482.         (garbage-collect)
  483.         (load "vms-patch")))
  484. + (if (fboundp 'integer-or-floatp)    ; preload some constants and 
  485. +     (progn                ; floating pt. functions if 
  486. +       (garbage-collect)            ; we have float support.
  487. +       (load "float-sup")))
  488.   
  489.   ;If you want additional libraries to be preloaded and their
  490.   ;doc strings kept in the DOC file rather than in core,
  491. diff -rc emacs-18.57/lisp/sort.el emacs/lisp/sort.el
  492. *** emacs-18.57/lisp/sort.el    Wed Jan  9 23:04:27 1991
  493. --- emacs/lisp/sort.el    Tue Aug 13 11:21:48 1991
  494. ***************
  495. *** 1,3 ****
  496. --- 1,16 ----
  497. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  498. + ;;                                         ;;
  499. + ;;    File:     sort.el                             ;;
  500. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  501. + ;;    Created:  Wed May 18 12:48:23 EDT 1988                     ;;
  502. + ;;    Contents: Gnu emacs code, with patches to make it work with floats   ;;
  503. + ;;                                         ;;
  504. + ;;    Copyright (c) 1988 Wolfgang Rupprecht.                     ;;
  505. + ;;    All rights reserved.                             ;;
  506. + ;;                                         ;;
  507. + ;;    $Log$                                     ;;
  508. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  509.   ;; Commands to sort text in an Emacs buffer.
  510.   ;; Copyright (C) 1986, 1987 Free Software Foundation, Inc.
  511.   
  512. ***************
  513. *** 199,204 ****
  514. --- 212,218 ----
  515.       (modify-syntax-entry ?\  " " table)
  516.       (modify-syntax-entry ?\t " " table)
  517.       (modify-syntax-entry ?\n " " table)
  518. +     (modify-syntax-entry ?\. "_" table)    ; for floating pt. numbers. -wsr
  519.       (setq sort-fields-syntax-table table)))
  520.   
  521.   (defun sort-numeric-fields (field beg end)
  522. ***************
  523. *** 216,222 ****
  524.                     (buffer-substring
  525.                       (point)
  526.                   (save-excursion
  527. !                   (skip-chars-forward "-0-9")
  528.                     (point))))))
  529.            nil))
  530.   
  531. --- 230,238 ----
  532.                     (buffer-substring
  533.                       (point)
  534.                   (save-excursion
  535. !                   ;; This is just wrong! Even without floats...
  536. !                   ;; (skip-chars-forward "-0-9")
  537. !                   (forward-sexp 1)
  538.                     (point))))))
  539.            nil))
  540.   
  541. *** emacs-18.57/lisp/startup.el    Wed Jan 16 05:19:04 1991
  542. --- emacs/lisp/startup.el    Tue Aug 13 10:53:14 1991
  543. ***************
  544. *** 1,3 ****
  545. --- 1,15 ----
  546. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  547. + ;;                                         ;;
  548. + ;;    File:     startup.el                             ;;
  549. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  550. + ;;    Created:  Thu Nov  5 16:58:42 EST 1987                     ;;
  551. + ;;    Contents: GNU startup file with floating point support              ;;
  552. + ;;                                         ;;
  553. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  554. + ;;    All rights reserved.                             ;;
  555. + ;;                                         ;;
  556. + ;;    $Log$                                     ;;
  557. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  558.   ;; Process Emacs shell arguments
  559.   ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  560.   
  561. ***************
  562. *** 166,171 ****
  563. --- 178,188 ----
  564.            (unwind-protect
  565.            (progn
  566.              (insert (emacs-version)
  567. +                ;; this next sexp can get nuked once FSF
  568. +                ;; owns this code. -wsr
  569. +                (if (featurep 'lisp-float-type)
  570. +                    "\nCopyright (C) 1987 Wolfgang Rupprecht."
  571. +                  "")
  572.                  "
  573.   Copyright (C) 1990 Free Software Foundation, Inc.\n")
  574.              ;; If keys have their default meanings,
  575. ***************
  576. *** 190,195 ****
  577. --- 207,221 ----
  578.   You may give out copies of Emacs; type \\[describe-copying] to see the conditions.
  579.   Type \\[describe-distribution] for information on getting the latest version.
  580.   Type \\[help-with-tutorial] for a tutorial on using Emacs.")))
  581. + ;;;
  582. + ;;; And now a message for the lawyer-slimes of this world. -wsr
  583. + ;;;
  584. +            (if (featurep 'lisp-float-type)
  585. +                (insert "\n
  586. + This version of emacs contains a floating point data type allowing you
  587. + do calculations with real numbers, just like a calculator.  This code
  588. + may not always yield the correct answers under all conditions.
  589. +     YOU ARE RESPONSIBLE FOR CHECKING THE ANSWERS!\n"))
  590.              (set-buffer-modified-p nil)
  591.              (sit-for 120))
  592.              (save-excursion
  593. diff -rc emacs-18.57/lisp/subr.el emacs/lisp/subr.el
  594. *** emacs-18.57/lisp/subr.el    Wed Jan  9 23:04:45 1991
  595. --- emacs/lisp/subr.el    Tue Aug 13 10:53:24 1991
  596. ***************
  597. *** 1,3 ****
  598. --- 1,15 ----
  599. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  600. + ;;                                         ;;
  601. + ;;    File:     subr.el                             ;;
  602. + ;;    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ;;
  603. + ;;    Created:  Thu Dec 31 14:01:32 EST 1987                     ;;
  604. + ;;    Contents: The Gnu subr.el file, with my float stuff             ;;
  605. + ;;                                         ;;
  606. + ;;    Copyright (c) 1987 Wolfgang Rupprecht.                     ;;
  607. + ;;    All rights reserved.                             ;;
  608. + ;;                                         ;;
  609. + ;;    $Log$                                     ;;
  610. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  611.   ;; Basic lisp subroutines for Emacs
  612.   ;; Copyright (C) 1985, 1986, 1990 Free Software Foundation, Inc.
  613.   
  614. ***************
  615. *** 150,156 ****
  616.   (fset 'move-marker 'set-marker)
  617.   (fset 'eql 'eq)
  618.   (fset 'not 'null)
  619. ! (fset 'numberp 'integerp)
  620.   (fset 'rplaca 'setcar)
  621.   (fset 'rplacd 'setcdr)
  622.   (fset 'beep 'ding) ;preserve lingual purtity
  623. --- 162,170 ----
  624.   (fset 'move-marker 'set-marker)
  625.   (fset 'eql 'eq)
  626.   (fset 'not 'null)
  627. ! (if (fboundp 'integer-or-floatp)
  628. !     (fset 'numberp 'integer-or-floatp)
  629. !   (fset 'numberp 'integerp))
  630.   (fset 'rplaca 'setcar)
  631.   (fset 'rplacd 'setcdr)
  632.   (fset 'beep 'ding) ;preserve lingual purtity
  633. diff -rc emacs-18.57/src/alloc.c emacs/src/alloc.c
  634. *** emacs-18.57/src/alloc.c    Sat Jan  5 01:12:10 1991
  635. --- emacs/src/alloc.c    Tue Aug 13 10:50:53 1991
  636. ***************
  637. *** 1,3 ****
  638. --- 1,15 ----
  639. + /******************************************************************************
  640. + *                                          *
  641. + *    File:     alloc.c                              *
  642. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  643. + *    Created:  Mon Nov  2 15:20:48 EST 1987                      *
  644. + *    Contents: GNU alloc.c with my float code                  *
  645. + *                                          *
  646. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  647. + *    All rights reserved.                              *
  648. + *                                          *
  649. + *    $Log$                                      *
  650. + ******************************************************************************/
  651.   /* Storage allocation and gc for GNU Emacs Lisp interpreter.
  652.      Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  653.   
  654. ***************
  655. *** 195,200 ****
  656. --- 207,287 ----
  657.     cons_free_list = ptr;
  658.   }
  659.   
  660. + #ifdef LISP_FLOAT_TYPE
  661. + /* Allocation of float cells, just like conses */
  662. + /* We store float cells inside of float_blocks, allocating a new
  663. +  float_block with malloc whenever necessary.  Float cells reclaimed by
  664. +  GC are put on a free list to be reallocated before allocating
  665. +  any new float cells from the latest float_block.
  666. +  Each float_block is just under 1020 bytes long,
  667. +  since malloc really allocates in units of powers of two
  668. +  and uses 4 bytes for its own overhead. */
  669. + #define FLOAT_BLOCK_SIZE \
  670. +   ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float))
  671. + struct float_block
  672. +   {
  673. +     struct float_block *next;
  674. +     struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
  675. +   };
  676. + struct float_block *float_block;
  677. + int float_block_index;
  678. + struct Lisp_Float *float_free_list;
  679. + void
  680. + init_float ()
  681. + {
  682. +   float_block = (struct float_block *) malloc (sizeof (struct float_block));
  683. +   float_block->next = 0;
  684. +   bzero (float_block->floats, sizeof float_block->floats);
  685. +   float_block_index = 0;
  686. +   float_free_list = 0;
  687. + }
  688. + /* Explicitly free a float cell.  */
  689. + free_float (ptr)
  690. +      struct Lisp_Float *ptr;
  691. + {
  692. +   XFASTINT (ptr->type) = (int) float_free_list;
  693. +   float_free_list = ptr;
  694. + }
  695. + Lisp_Object
  696. + make_float (float_value)
  697. +      double float_value;
  698. + {
  699. +   register Lisp_Object val;
  700. +   if (float_free_list)
  701. +     {
  702. +       XSET (val, Lisp_Float, float_free_list);
  703. +       float_free_list = (struct Lisp_Float *) XFASTINT (float_free_list->type);
  704. +     }
  705. +   else
  706. +     {
  707. +       if (float_block_index == FLOAT_BLOCK_SIZE)
  708. +     {
  709. +       register struct float_block *new = (struct float_block *) malloc (sizeof (struct float_block));
  710. +       if (!new) memory_full ();
  711. +       new->next = float_block;
  712. +       float_block = new;
  713. +       float_block_index = 0;
  714. +     }
  715. +       XSET (val, Lisp_Float, &float_block->floats[float_block_index++]);
  716. +     }
  717. +   XFLOAT (val)->data = float_value;
  718. +   XFLOAT (val)->type = 0;    /* bug chasing -wsr */
  719. +   consing_since_gc += sizeof (struct Lisp_Float);
  720. +   return val;
  721. + }
  722. + #endif LISP_FLOAT_TYPE
  723.   DEFUN ("cons", Fcons, Scons, 2, 2, 0,
  724.     "Create a new cons, give it CAR and CDR as components, and return it.")
  725.     (car, cdr)
  726. ***************
  727. *** 650,656 ****
  728. --- 737,761 ----
  729.     return new;
  730.   }
  731.   
  732. + #ifdef LISP_FLOAT_TYPE
  733.   Lisp_Object
  734. + pure_float (num)
  735. +      double num;
  736. + {
  737. +   register Lisp_Object new;
  738. +   if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
  739. +     error ("Pure Lisp storage exhausted");
  740. +   XSET (new, Lisp_Float, PUREBEG + pureptr);
  741. +   pureptr += sizeof (struct Lisp_Float);
  742. +   XFLOAT (new)->data = num;
  743. +   XFLOAT (new)->type = 0;    /* bug chasing -wsr */
  744. +   return new;
  745. + }
  746. + #endif LISP_FLOAT_TYPE
  747. + Lisp_Object
  748.   make_pure_vector (len)
  749.        int len;
  750.   {
  751. ***************
  752. *** 695,700 ****
  753. --- 800,810 ----
  754.       case Lisp_Cons:
  755.         return pure_cons (XCONS (obj)->car, XCONS (obj)->cdr);
  756.   
  757. + #ifdef LISP_FLOAT_TYPE
  758. +     case Lisp_Float:
  759. +       return pure_float (XFLOAT (obj)->data);
  760. + #endif LISP_FLOAT_TYPE
  761.       case Lisp_String:
  762.         return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size);
  763.   
  764. ***************
  765. *** 784,794 ****
  766. --- 894,909 ----
  767.   
  768.   int total_conses, total_markers, total_symbols, total_string_size, total_vector_size;
  769.   int total_free_conses, total_free_markers, total_free_symbols;
  770. + #ifdef LISP_FLOAT_TYPE
  771. + int total_free_floats, total_floats;
  772. + #endif LISP_FLOAT_TYPE
  773.   
  774.   static void mark_object (), mark_buffer ();
  775.   static void clear_marks (), gc_sweep ();
  776.   static void compact_strings ();
  777.   
  778. + #ifndef LISP_FLOAT_TYPE
  779.   DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
  780.     "Reclaim storage for Lisp objects no longer needed.\n\
  781.   Returns info on amount of space in use:\n\
  782. ***************
  783. *** 795,802 ****
  784.    ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  785.     (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  786.   Garbage collection happens automatically if you cons more than\n\
  787. ! gc-cons-threshold  bytes of Lisp data since previous garbage collection.")
  788.     ()
  789.   {
  790.     register struct gcpro *tail;
  791.     register struct specbinding *bind;
  792. --- 910,930 ----
  793.    ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  794.     (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  795.   Garbage collection happens automatically if you cons more than\n\
  796. ! gc-cons-threshold  bytes of Lisp data since previous garbage collection."
  797. !        )
  798.     ()
  799. + #else LISP_FLOAT_TYPE
  800. + DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",  "Reclaim storage for Lisp objects no longer needed.\n\
  801. + Returns info on amount of space in use:\n\
  802. +  ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  803. +   (USED-MARKERS . FREE-MARKERS) (USED-FLOATS . FREE-FLOATS) \n\
  804. +   USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  805. + Garbage collection happens automatically if you cons more than\n\
  806. + gc-cons-threshold  bytes of Lisp data since previous garbage collection."
  807. +        )
  808. +   ()
  809. + #endif LISP_FLOAT_TYPE
  810.   {
  811.     register struct gcpro *tail;
  812.     register struct specbinding *bind;
  813. ***************
  814. *** 919,927 ****
  815. --- 1047,1064 ----
  816.                     make_number (total_free_symbols)),
  817.                  Fcons (Fcons (make_number (total_markers),
  818.                        make_number (total_free_markers)),
  819. + #ifdef LISP_FLOAT_TYPE
  820. +                   Fcons (Fcons (make_number (total_floats),
  821. +                         make_number (total_free_floats)),
  822. +                      Fcons (make_number (total_string_size),
  823. +                         Fcons (make_number (total_vector_size),
  824. +                            Qnil))))));
  825. + #else not LISP_FLOAT_TYPE
  826.                     Fcons (make_number (total_string_size),
  827.                        Fcons (make_number (total_vector_size),
  828.                           Qnil)))));
  829. + #endif LISP_FLOAT_TYPE
  830.   }
  831.   
  832.   #if 0
  833. ***************
  834. *** 1113,1118 ****
  835. --- 1250,1261 ----
  836.       goto loop;
  837.         }
  838.   
  839. + #ifdef LISP_FLOAT_TYPE
  840. +  case Lisp_Float:
  841. +       XMARK (XFLOAT (obj)->type);
  842. +       break;
  843. + #endif LISP_FLOAT_TYPE
  844.       case Lisp_Buffer:
  845.         if (!XMARKBIT (XBUFFER (obj)->name))
  846.       mark_buffer (obj);
  847. ***************
  848. *** 1193,1199 ****
  849. --- 1336,1372 ----
  850.       total_conses = num_used;
  851.       total_free_conses = num_free;
  852.     }
  853. + #ifdef LISP_FLOAT_TYPE
  854. +   /* Put all unmarked floats on free list */
  855. +   {
  856. +     register struct float_block *fblk;
  857. +     register int lim = float_block_index;
  858. +     register int num_free = 0, num_used = 0;
  859.   
  860. +     float_free_list = 0;
  861. +   
  862. +     for (fblk = float_block; fblk; fblk = fblk->next)
  863. +       {
  864. +     register int i;
  865. +     for (i = 0; i < lim; i++)
  866. +       if (!XMARKBIT (fblk->floats[i].type))
  867. +         {
  868. +           XFASTINT (fblk->floats[i].type) = (int) float_free_list;
  869. +           num_free++;
  870. +           float_free_list = &fblk->floats[i];
  871. +         }
  872. +       else
  873. +         {
  874. +           num_used++;
  875. +           XUNMARK (fblk->floats[i].type);
  876. +         }
  877. +     lim = FLOAT_BLOCK_SIZE;
  878. +       }
  879. +     total_floats = num_used;
  880. +     total_free_floats = num_free;
  881. +   }
  882. + #endif LISP_FLOAT_TYPE
  883.     /* Put all unmarked symbols on free list */
  884.     {
  885.       register struct symbol_block *sblk;
  886. ***************
  887. *** 1484,1489 ****
  888. --- 1657,1665 ----
  889.     all_vectors = 0;
  890.     init_strings ();
  891.     init_cons ();
  892. + #ifdef LISP_FLOAT_TYPE
  893. +   init_float ();
  894. + #endif LISP_FLOAT_TYPE
  895.     init_symbol ();
  896.     init_marker ();
  897.     gcprolist = 0;
  898. diff -rc emacs-18.57/src/callint.c emacs/src/callint.c
  899. *** emacs-18.57/src/callint.c    Sat Jan  5 01:13:13 1991
  900. --- emacs/src/callint.c    Tue Aug 13 10:51:08 1991
  901. ***************
  902. *** 352,358 ****
  903. --- 352,363 ----
  904.       case 'n':        /* Read number from minibuffer.  */
  905.         do
  906.           args[i] = Fread_minibuffer (build_string (prompt), Qnil);
  907. + #ifdef LISP_FLOAT_TYPE
  908. +       while ((XTYPE (args[i]) != Lisp_Int) &&
  909. +          (XTYPE (args[i]) != Lisp_Float));
  910. + #else
  911.         while (XTYPE (args[i]) != Lisp_Int);
  912. + #endif
  913.         visargs[i] = last_minibuf_string;
  914.         break;
  915.   
  916. diff -rc emacs-18.57/src/config.h-dist emacs/src/config.h-dist
  917. *** emacs-18.57/src/config.h-dist    Tue Jan  8 19:24:37 1991
  918. --- emacs/src/config.h-dist    Tue Aug 13 10:51:26 1991
  919. ***************
  920. *** 17,23 ****
  921. --- 17,28 ----
  922.   along with GNU Emacs; see the file COPYING.  If not, write to
  923.   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  924.   
  925. + /* This is a hack feature added by me.
  926. +  * It probably won't break anything too badly, but it may not do
  927. +  * much for you either. -Wolfgang Rupprecht 10/25/87
  928. +  */
  929.   
  930. + /* #define LISP_FLOAT_TYPE        /* define this for floating pt. numbers */
  931.   
  932.   /* Include here a s- file that describes the system type you are using.
  933.      See the file ../etc/MACHINES for a list of systems and
  934. diff -rc emacs-18.57/src/crt0.c emacs/src/crt0.c
  935. *** emacs-18.57/src/crt0.c    Tue Jan  8 18:23:04 1991
  936. --- emacs/src/crt0.c    Tue Aug 13 10:51:36 1991
  937. ***************
  938. *** 287,292 ****
  939. --- 287,297 ----
  940.   
  941.   _start ()
  942.   {
  943. + #ifdef LISP_FLOAT_TYPE
  944. + # ifdef sun3
  945. +   finitfp_();
  946. + # endif
  947. + #endif
  948.   /* On 68000, _start pushes a6 onto stack  */
  949.     start1 ();
  950.   }
  951. diff -rc emacs-18.57/src/data.c emacs/src/data.c
  952. *** emacs-18.57/src/data.c    Sat Jan  5 01:15:14 1991
  953. --- emacs/src/data.c    Tue Aug 13 11:15:28 1991
  954. ***************
  955. *** 1,3 ****
  956. --- 1,15 ----
  957. + /******************************************************************************
  958. + *                                          *
  959. + *    File:     data.c                              *
  960. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  961. + *    Created:  Mon Nov  2 15:22:23 EST 1987                      *
  962. + *    Contents: GNU data.c with my float code                      *
  963. + *                                          *
  964. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  965. + *    All rights reserved.                              *
  966. + *                                          *
  967. + *    $Log$                                      *
  968. + ******************************************************************************/
  969.   /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
  970.      Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  971.   
  972. ***************
  973. *** 27,32 ****
  974. --- 39,48 ----
  975.   #include "buffer.h"
  976.   #endif
  977.   
  978. + #ifdef LISP_FLOAT_TYPE
  979. + #include <math.h>
  980. + #endif LISP_FLOAT_TYPE
  981.   Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
  982.   Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
  983.   Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
  984. ***************
  985. *** 40,46 ****
  986. --- 56,67 ----
  987.   Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
  988.   Lisp_Object Qboundp, Qfboundp;
  989.   Lisp_Object Qcdr;
  990. + #ifdef LISP_FLOAT_TYPE
  991. + Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
  992. + #endif LISP_FLOAT_TYPE
  993.   
  994.   Lisp_Object
  995.   wrong_type_argument (predicate, value)
  996.        register Lisp_Object predicate, value;
  997. ***************
  998. *** 176,181 ****
  999. --- 197,237 ----
  1000.     return Qnil;
  1001.   }
  1002.   
  1003. + #ifdef LISP_FLOAT_TYPE
  1004. + DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0,
  1005. +        "T if OBJECT is a floating pt. number.")
  1006. +   (obj)
  1007. +      Lisp_Object obj;
  1008. + {
  1009. +   if (XTYPE (obj) == Lisp_Float)
  1010. +     return Qt;
  1011. +   return Qnil;
  1012. + }
  1013. + DEFUN ("integer-or-floatp", Finteger_or_floatp, Sinteger_or_floatp,
  1014. +        1, 1, 0, "T if OBJECT is a floating pt. or normal number.")
  1015. +   (obj)
  1016. +      Lisp_Object obj;
  1017. + {
  1018. +   if ((XTYPE (obj) == Lisp_Float) || (XTYPE (obj) == Lisp_Int))
  1019. +     return Qt;
  1020. +   return Qnil;
  1021. + }
  1022. + DEFUN ("integer-or-float-or-marker-p", Finteger_or_float_or_marker_p,
  1023. +        Sinteger_or_float_or_marker_p, 1, 1, 0,
  1024. +        "T if OBJECT is a floating pointt, normal number, or marker.")
  1025. +   (obj)
  1026. +      Lisp_Object obj;
  1027. + {
  1028. +   if ((XTYPE (obj) == Lisp_Float) ||
  1029. +       (XTYPE (obj) == Lisp_Int) ||
  1030. +       (XTYPE (obj) == Lisp_Marker))
  1031. +     return Qt;
  1032. +   return Qnil;
  1033. + }
  1034. + #endif LISP_FLOAT_TYPE
  1035.   DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, "T if OBJECT is a nonnegative number.")
  1036.     (obj)
  1037.        Lisp_Object obj;
  1038. ***************
  1039. *** 971,978 ****
  1040. --- 1027,1051 ----
  1041.     (num1, num2)
  1042.        register Lisp_Object num1, num2;
  1043.   {
  1044. + #ifdef LISP_FLOAT_TYPE
  1045. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1046. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1047. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1048. +     {
  1049. +       double f1, f2;
  1050. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1051. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1052. +       if (f1 == f2)
  1053. +     return Qt;
  1054. +       return Qnil;
  1055. +     }
  1056. + #else
  1057.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1058.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1059. + #endif LISP_FLOAT_TYPE
  1060.   
  1061.     if (XINT (num1) == XINT (num2))
  1062.       return Qt;
  1063. ***************
  1064. *** 984,991 ****
  1065. --- 1057,1080 ----
  1066.     (num1, num2)
  1067.        register Lisp_Object num1, num2;
  1068.   {
  1069. + #ifdef LISP_FLOAT_TYPE
  1070. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1071. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1072. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1073. +     {
  1074. +       double f1, f2;
  1075. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1076. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1077. +       if (f1 < f2)
  1078. +     return Qt;
  1079. +       return Qnil;
  1080. +     }
  1081. + #else
  1082.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1083.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1084. + #endif LISP_FLOAT_TYPE
  1085.   
  1086.     if (XINT (num1) < XINT (num2))
  1087.       return Qt;
  1088. ***************
  1089. *** 997,1004 ****
  1090. --- 1086,1109 ----
  1091.     (num1, num2)
  1092.        register Lisp_Object num1, num2;
  1093.   {
  1094. + #ifdef LISP_FLOAT_TYPE
  1095. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1096. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1097. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1098. +     {
  1099. +       double f1, f2;
  1100. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1101. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1102. +       if (f1 > f2)
  1103. +     return Qt;
  1104. +       return Qnil;
  1105. +     }
  1106. + #else
  1107.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1108.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1109. + #endif LISP_FLOAT_TYPE
  1110.   
  1111.     if (XINT (num1) > XINT (num2))
  1112.       return Qt;
  1113. ***************
  1114. *** 1010,1017 ****
  1115. --- 1115,1138 ----
  1116.     (num1, num2)
  1117.        register Lisp_Object num1, num2;
  1118.   {
  1119. + #ifdef LISP_FLOAT_TYPE
  1120. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1121. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1122. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1123. +     {
  1124. +       double f1, f2;
  1125. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1126. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1127. +       if (f1 <= f2)
  1128. +     return Qt;
  1129. +       return Qnil;
  1130. +     }
  1131. + #else
  1132.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1133.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1134. + #endif LISP_FLOAT_TYPE
  1135.   
  1136.     if (XINT (num1) <= XINT (num2))
  1137.       return Qt;
  1138. ***************
  1139. *** 1023,1030 ****
  1140. --- 1144,1167 ----
  1141.     (num1, num2)
  1142.        register Lisp_Object num1, num2;
  1143.   {
  1144. + #ifdef LISP_FLOAT_TYPE
  1145. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1146. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1147. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1148. +     {
  1149. +       double f1, f2;
  1150. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1151. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1152. +       if (f1 >= f2)
  1153. +     return Qt;
  1154. +       return Qnil;
  1155. +     }
  1156. + #else
  1157.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1158.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1159. + #endif LISP_FLOAT_TYPE
  1160.   
  1161.     if (XINT (num1) >= XINT (num2))
  1162.       return Qt;
  1163. ***************
  1164. *** 1036,1043 ****
  1165. --- 1173,1196 ----
  1166.     (num1, num2)
  1167.        register Lisp_Object num1, num2;
  1168.   {
  1169. + #ifdef LISP_FLOAT_TYPE
  1170. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1171. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1172. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1173. +     {
  1174. +       double f1, f2;
  1175. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1176. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1177. +       if (f1 != f2)
  1178. +     return Qt;
  1179. +       return Qnil;
  1180. +     }
  1181. + #else
  1182.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1183.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1184. + #endif LISP_FLOAT_TYPE
  1185.   
  1186.     if (XINT (num1) != XINT (num2))
  1187.       return Qt;
  1188. ***************
  1189. *** 1048,1054 ****
  1190. --- 1201,1218 ----
  1191.     (num)
  1192.        register Lisp_Object num;
  1193.   {
  1194. + #ifdef LISP_FLOAT_TYPE
  1195. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1196. +   if (XTYPE(num) == Lisp_Float)
  1197. +     {
  1198. +       if (XFLOAT(num)->data == 0.0)
  1199. +     return Qt;
  1200. +       return Qnil;
  1201. +     }
  1202. + #else
  1203.     CHECK_NUMBER (num, 0);
  1204. + #endif LISP_FLOAT_TYPE
  1205.   
  1206.     if (!XINT (num))
  1207.       return Qt;
  1208. ***************
  1209. *** 1062,1068 ****
  1210. --- 1226,1246 ----
  1211.   {
  1212.     char buffer[20];
  1213.   
  1214. + #ifndef LISP_FLOAT_TYPE
  1215.     CHECK_NUMBER (num, 0);
  1216. + #else
  1217. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1218. +   if (XTYPE(num) == Lisp_Float)
  1219. +     {
  1220. +       char pigbuf[350];    /* see comments in float_to_string */
  1221. +       float_to_string (pigbuf, XFLOAT(num)->data);
  1222. +       return build_string (pigbuf);      
  1223. +     }
  1224. + #endif LISP_FLOAT_TYPE
  1225.     sprintf (buffer, "%d", XINT (num));
  1226.     return build_string (buffer);
  1227.   }
  1228. ***************
  1229. *** 1073,1078 ****
  1230. --- 1251,1260 ----
  1231.        register Lisp_Object str, flag;
  1232.   {
  1233.     CHECK_STRING (str, 0);
  1234. + #ifdef LISP_FLOAT_TYPE
  1235. +   if (isfloat_string (XSTRING (str)->data))
  1236. +     return make_float (atof(XSTRING (str)->data));
  1237. + #endif LISP_FLOAT_TYPE
  1238.     return make_number (atoi (XSTRING (str)->data));
  1239.   }
  1240.     
  1241. ***************
  1242. *** 1111,1117 ****
  1243. --- 1293,1307 ----
  1244.     for (argnum = 0; argnum < nargs; argnum++)
  1245.       {
  1246.         val = args[argnum];    /* using args[argnum] as argument to CHECK_NUMBER_... */
  1247. + #ifdef LISP_FLOAT_TYPE
  1248. +       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
  1249. +       if (XTYPE(val) == Lisp_Float) /* time to do serious math */
  1250. +     return (float_arith_driver((double) accum, argnum, code,
  1251. +                    nargs, args));
  1252. + #else
  1253.         CHECK_NUMBER_COERCE_MARKER (val, argnum);
  1254. + #endif LISP_FLOAT_TYPE
  1255.         args[argnum] = val;    /* runs into a compiler bug. */
  1256.         next = XINT (args[argnum]);
  1257.   #ifdef SWITCH_ENUM_BUG
  1258. ***************
  1259. *** 1143,1148 ****
  1260. --- 1333,1418 ----
  1261.     return val;
  1262.   }
  1263.   
  1264. + #ifdef LISP_FLOAT_TYPE
  1265. + Lisp_Object
  1266. + float_arith_driver
  1267. +   (accum, argnum, code, nargs, args)
  1268. +      double accum;
  1269. +      register int argnum;
  1270. +      enum arithop code;
  1271. +      int nargs;
  1272. +      register Lisp_Object *args;
  1273. + {
  1274. +   register Lisp_Object val;
  1275. +   double next;
  1276. +   
  1277. +   for (; argnum < nargs; argnum++)
  1278. +     {
  1279. +       val = args[argnum];    /* using args[argnum] as argument to CHECK_NUMBER_... */
  1280. +       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
  1281. +       if (XTYPE(val) == Lisp_Float)
  1282. +     {
  1283. +       next = XFLOAT(val)->data;
  1284. +     }
  1285. +       else
  1286. +     {
  1287. +       args[argnum] = val;    /* runs into a compiler bug. */
  1288. +       next = XINT (args[argnum]);
  1289. +     }
  1290. + #ifdef SWITCH_ENUM_BUG
  1291. +       switch ((int) code)
  1292. + #else
  1293. +       switch (code)
  1294. + #endif
  1295. +     {
  1296. +     case Aadd: accum += next; break;
  1297. +     case Asub:
  1298. +       if (!argnum && nargs != 1)
  1299. +         next = - next;
  1300. +       accum -= next;
  1301. +       break;
  1302. +     case Amult: accum *= next; break;
  1303. +     case Adiv:
  1304. +       if (!argnum) accum = next;
  1305. +       else accum /= next;
  1306. +       break;
  1307. + #ifdef pigs_had_wings
  1308. +     case Alogand: accum &= next; break;
  1309. +     case Alogior: accum |= next; break;
  1310. +     case Alogxor: accum ^= next; break;
  1311. + #else
  1312. +     case Alogand:
  1313. +     case Alogior:
  1314. +     case Alogxor:
  1315. +       return (wrong_type_argument (Qinteger_or_marker_p, val));
  1316. +       break;
  1317. + #endif
  1318. +     case Amax: if (!argnum || next > accum) accum = next; break;
  1319. +     case Amin: if (!argnum || next < accum) accum = next; break;
  1320. +     }
  1321. +     }
  1322. +   return make_float(accum);
  1323. + }
  1324. + DEFUN ("logb", Flogb, Slogb, 1, 1, 0,
  1325. +  "Returns the integer that is the base 2 log of ARG.\n\
  1326. + This is the same as the exponent of a float.")
  1327. +      (num)
  1328. + Lisp_Object num;
  1329. + {
  1330. +   Lisp_Object val;
  1331. +   double f;
  1332. +   CHECK_NUMBER_OR_FLOAT(num, 0);
  1333. +   f = (XTYPE(num) == Lisp_Float) ? XFLOAT(num)->data : XINT(num);
  1334. +   val = logb(f);
  1335. +   XSET(val, Lisp_Int, val);
  1336. +   return val;
  1337. + }
  1338. + #endif LISP_FLOAT_TYPE
  1339.   DEFUN ("+", Fplus, Splus, 0, MANY, 0,
  1340.     "Return sum of any number of numbers.")
  1341.     (nargs, args)
  1342. ***************
  1343. *** 1187,1195 ****
  1344. --- 1457,1478 ----
  1345.        register Lisp_Object num1, num2;
  1346.   {
  1347.     Lisp_Object val;
  1348. + #ifdef LISP_FLOAT_TYPE
  1349. +   CHECK_NUMBER_OR_FLOAT (num1, 0);
  1350. +   CHECK_NUMBER_OR_FLOAT (num2, 0);
  1351.   
  1352. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  1353. +     {
  1354. +       double f1, f2;
  1355. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1356. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1357. +       return (make_float(drem(f1,f2)));
  1358. +     }
  1359. + #else
  1360.     CHECK_NUMBER (num1, 0);
  1361.     CHECK_NUMBER (num2, 1);
  1362. + #endif LISP_FLOAT_TYPE
  1363.   
  1364.     XSET (val, Lisp_Int, XINT (num1) % XINT (num2));
  1365.     return val;
  1366. ***************
  1367. *** 1283,1289 ****
  1368. --- 1566,1579 ----
  1369.     (num)
  1370.        register Lisp_Object num;
  1371.   {
  1372. + #ifdef LISP_FLOAT_TYPE
  1373. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
  1374. +   if (XTYPE(num) == Lisp_Float)
  1375. +     return (make_float((1.0) + XFLOAT(num)->data));
  1376. + #else
  1377.     CHECK_NUMBER_COERCE_MARKER (num, 0);
  1378. + #endif LISP_FLOAT_TYPE
  1379.     XSETINT (num, XFASTINT (num) + 1);
  1380.     return num;
  1381.   }
  1382. ***************
  1383. *** 1293,1299 ****
  1384. --- 1583,1596 ----
  1385.     (num)
  1386.        register Lisp_Object num;
  1387.   {
  1388. + #ifdef LISP_FLOAT_TYPE
  1389. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
  1390. +   if (XTYPE(num) == Lisp_Float)
  1391. +     return (make_float((-1.0) + XFLOAT(num)->data));
  1392. + #else
  1393.     CHECK_NUMBER_COERCE_MARKER (num, 0);
  1394. + #endif LISP_FLOAT_TYPE
  1395.     XSETINT (num, XFASTINT (num) - 1);
  1396.     return num;
  1397.   }
  1398. ***************
  1399. *** 1307,1312 ****
  1400. --- 1604,2160 ----
  1401.     XSETINT (num, ~XFASTINT (num));
  1402.     return num;
  1403.   }
  1404. + #ifdef LISP_FLOAT_TYPE
  1405. + DEFUN ("acos", Facos, Sacos, 1, 1, 0,
  1406. +   "Return the inverse cosine of ARG.")
  1407. +   (num)
  1408. +      register Lisp_Object num;
  1409. + {
  1410. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1411. +   if (XTYPE(num) == Lisp_Float)
  1412. +     return (make_float (acos(XFLOAT(num)->data)));
  1413. +   return (make_float (acos((double) XINT(num))));
  1414. + }
  1415. + DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
  1416. +   "Return the inverse hyperbolic cosine of ARG.")
  1417. +   (num)
  1418. +      register Lisp_Object num;
  1419. + {
  1420. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1421. +   if (XTYPE(num) == Lisp_Float)
  1422. +     return (make_float (acosh(XFLOAT(num)->data)));
  1423. +   return (make_float (acosh((double) XINT(num))));
  1424. + }
  1425. + DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
  1426. +   "Return the inverse sine of ARG.")
  1427. +   (num)
  1428. +      register Lisp_Object num;
  1429. + {
  1430. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1431. +   if (XTYPE(num) == Lisp_Float)
  1432. +     return (make_float (asin(XFLOAT(num)->data)));
  1433. +   return (make_float (asin((double) XINT(num))));
  1434. + }
  1435. + DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0,
  1436. +   "Return the inverse hyperbolic sine of ARG.")
  1437. +   (num)
  1438. +      register Lisp_Object num;
  1439. + {
  1440. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1441. +   if (XTYPE(num) == Lisp_Float)
  1442. +     return (make_float (asinh(XFLOAT(num)->data)));
  1443. +   return (make_float (asinh((double) XINT(num))));
  1444. + }
  1445. + DEFUN ("atan", Fatan, Satan, 1, 1, 0,
  1446. +   "Return the inverse tangent of ARG.")
  1447. +   (num)
  1448. +      register Lisp_Object num;
  1449. + {
  1450. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1451. +   if (XTYPE(num) == Lisp_Float)
  1452. +     return (make_float (atan(XFLOAT(num)->data)));
  1453. +   return (make_float (atan((double) XINT(num))));
  1454. + }
  1455. + DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0,
  1456. +   "Return the inverse hyperbolic tangent of ARG.")
  1457. +   (num)
  1458. +      register Lisp_Object num;
  1459. + {
  1460. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1461. +   if (XTYPE(num) == Lisp_Float)
  1462. +     return (make_float (atanh(XFLOAT(num)->data)));
  1463. +   return (make_float (atanh((double) XINT(num))));
  1464. + }
  1465. + DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
  1466. +   "Return the cube root of ARG.")
  1467. +   (num)
  1468. +      register Lisp_Object num;
  1469. + {
  1470. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1471. +   if (XTYPE(num) == Lisp_Float)
  1472. +     return (make_float (cbrt(XFLOAT(num)->data)));
  1473. +   return (make_float (cbrt((double) XINT(num))));
  1474. + }
  1475. + DEFUN ("cos", Fcos, Scos, 1, 1, 0,
  1476. +   "Return the cosine of ARG.")
  1477. +   (num)
  1478. +      register Lisp_Object num;
  1479. + {
  1480. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1481. +   if (XTYPE(num) == Lisp_Float)
  1482. +     return (make_float (cos(XFLOAT(num)->data)));
  1483. +   return (make_float (cos((double) XINT(num))));
  1484. + }
  1485. + DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0,
  1486. +   "Return the hyperbolic cosine of ARG.")
  1487. +   (num)
  1488. +      register Lisp_Object num;
  1489. + {
  1490. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1491. +   if (XTYPE(num) == Lisp_Float)
  1492. +     return (make_float (cosh(XFLOAT(num)->data)));
  1493. +   return (make_float (cosh((double) XINT(num))));
  1494. + }
  1495. + DEFUN ("erf", Ferf, Serf, 1, 1, 0,
  1496. +   "Return the mathematical error function of ARG.")
  1497. +   (num)
  1498. +      register Lisp_Object num;
  1499. + {
  1500. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1501. +   if (XTYPE(num) == Lisp_Float)
  1502. +     return (make_float (erf(XFLOAT(num)->data)));
  1503. +   return (make_float (erf((double) XINT(num))));
  1504. + }
  1505. + DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
  1506. +   "Return the complementary error function of ARG.")
  1507. +   (num)
  1508. +      register Lisp_Object num;
  1509. + {
  1510. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1511. +   if (XTYPE(num) == Lisp_Float)
  1512. +     return (make_float (erfc(XFLOAT(num)->data)));
  1513. +   return (make_float (erfc((double) XINT(num))));
  1514. + }
  1515. + DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
  1516. +   "Return the exponential base e of ARG.")
  1517. +   (num)
  1518. +      register Lisp_Object num;
  1519. + {
  1520. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1521. +   if (XTYPE(num) == Lisp_Float)
  1522. +     return (make_float (exp(XFLOAT(num)->data)));
  1523. +   return (make_float (exp((double) XINT(num))));
  1524. + }
  1525. + DEFUN ("expm1", Fexpm1, Sexpm1, 1, 1, 0,
  1526. +   "Return the exp(x)-1 of ARG.")
  1527. +   (num)
  1528. +      register Lisp_Object num;
  1529. + {
  1530. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1531. +   if (XTYPE(num) == Lisp_Float)
  1532. +     return (make_float (expm1(XFLOAT(num)->data)));
  1533. +   return (make_float (expm1((double) XINT(num))));
  1534. + }
  1535. + DEFUN ("j0", Fj0, Sj0, 1, 1, 0,
  1536. +   "Return the bessel function j0 of ARG.")
  1537. +   (num)
  1538. +      register Lisp_Object num;
  1539. + {
  1540. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1541. +   if (XTYPE(num) == Lisp_Float)
  1542. +     return (make_float (j0(XFLOAT(num)->data)));
  1543. +   return (make_float (j0((double) XINT(num))));
  1544. + }
  1545. + DEFUN ("j1", Fj1, Sj1, 1, 1, 0,
  1546. +   "Return the bessel function j1 of ARG.")
  1547. +   (num)
  1548. +      register Lisp_Object num;
  1549. + {
  1550. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1551. +   if (XTYPE(num) == Lisp_Float)
  1552. +     return (make_float (j1(XFLOAT(num)->data)));
  1553. +   return (make_float (j1((double) XINT(num))));
  1554. + }
  1555. + DEFUN ("jn", Fjn, Sjn, 2, 2, 0,
  1556. + "Return the nth ORDER bessel function output jn of ARG.  First arg is\n\
  1557. + the ORDER of the bessel, and is truncated to an integer.")
  1558. +   (num1, num2)
  1559. +      register Lisp_Object num1, num2;
  1560. + {
  1561. +   int i1;
  1562. +   double f2;
  1563. +   CHECK_NUMBER_OR_FLOAT (num1, 0);
  1564. +   CHECK_NUMBER_OR_FLOAT (num2, 0);
  1565. +   i1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1566. +   f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1567. +   return (make_float (jn(i1, f2)));
  1568. + }
  1569. + DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
  1570. +   "Return the log gamma of ARG.")
  1571. +   (num)
  1572. +      register Lisp_Object num;
  1573. + {
  1574. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1575. +   if (XTYPE(num) == Lisp_Float)
  1576. +     return (make_float (lgamma(XFLOAT(num)->data)));
  1577. +   return (make_float (lgamma((double) XINT(num))));
  1578. + }
  1579. + DEFUN ("log", Flog, Slog, 1, 1, 0,
  1580. +   "Return the natural logarithm of ARG.")
  1581. +   (num)
  1582. +      register Lisp_Object num;
  1583. + {
  1584. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1585. +   if (XTYPE(num) == Lisp_Float)
  1586. +     return (make_float (log(XFLOAT(num)->data)));
  1587. +   return (make_float (log((double) XINT(num))));
  1588. + }
  1589. + DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
  1590. +   "Return the logarithm base 10 of ARG.")
  1591. +   (num)
  1592. +      register Lisp_Object num;
  1593. + {
  1594. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1595. +   if (XTYPE(num) == Lisp_Float)
  1596. +     return (make_float (log10(XFLOAT(num)->data)));
  1597. +   return (make_float (log10((double) XINT(num))));
  1598. + }
  1599. + DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0,
  1600. +   "Return the log(1+x) of ARG.")
  1601. +   (num)
  1602. +      register Lisp_Object num;
  1603. + {
  1604. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1605. +   if (XTYPE(num) == Lisp_Float)
  1606. +     return (make_float (log1p(XFLOAT(num)->data)));
  1607. +   return (make_float (log1p((double) XINT(num))));
  1608. + }
  1609. + DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
  1610. +   "Return the exponential x ** y.")
  1611. +   (num1, num2)
  1612. +      register Lisp_Object num1, num2;
  1613. + {
  1614. +   double f1, f2;
  1615. +   CHECK_NUMBER_OR_FLOAT (num1, 0);
  1616. +   CHECK_NUMBER_OR_FLOAT (num2, 0);
  1617. +   if ((XTYPE(num1) == Lisp_Int) && /* common lisp spec */
  1618. +       (XTYPE(num2) == Lisp_Int)) /* don't promote, if both are ints */
  1619. +     {                /* this can be improved by pre-calculating */
  1620. +       int acc, x, y;        /* some binary powers of x then acumulating */
  1621. +                 /* these, therby saving some time. -wsr */
  1622. +       x = XINT(num1);
  1623. +       y = XINT(num2);
  1624. +       acc = 1;
  1625. +       
  1626. +       if (y < 0)
  1627. +     {
  1628. +       for (; y < 0; y++)
  1629. +           acc /= x;
  1630. +     }
  1631. +       else
  1632. +     {
  1633. +       for (; y > 0; y--)
  1634. +           acc *= x;
  1635. +     }
  1636. +       return (XSET(x , Lisp_Int, acc));
  1637. +     }
  1638. +   f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1639. +   f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1640. +   return (make_float (pow(f1, f2)));
  1641. + }
  1642. + DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
  1643. +   "Return the sine of ARG.")
  1644. +   (num)
  1645. +      register Lisp_Object num;
  1646. + {
  1647. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1648. +   if (XTYPE(num) == Lisp_Float)
  1649. +     return (make_float (sin(XFLOAT(num)->data)));
  1650. +   return (make_float (sin((double) XINT(num))));
  1651. + }
  1652. + DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
  1653. +   "Return the hyperbolic sine of ARG.")
  1654. +   (num)
  1655. +      register Lisp_Object num;
  1656. + {
  1657. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1658. +   if (XTYPE(num) == Lisp_Float)
  1659. +     return (make_float (sinh(XFLOAT(num)->data)));
  1660. +   return (make_float (sinh((double) XINT(num))));
  1661. + }
  1662. + DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
  1663. +   "Return the square root of ARG.")
  1664. +   (num)
  1665. +      register Lisp_Object num;
  1666. + {
  1667. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1668. +   if (XTYPE(num) == Lisp_Float)
  1669. +     return (make_float (sqrt(XFLOAT(num)->data)));
  1670. +   return (make_float (sqrt((double) XINT(num))));
  1671. + }
  1672. + DEFUN ("tan", Ftan, Stan, 1, 1, 0,
  1673. +   "Return the tangent of ARG.")
  1674. +   (num)
  1675. +      register Lisp_Object num;
  1676. + {
  1677. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1678. +   if (XTYPE(num) == Lisp_Float)
  1679. +     return (make_float (tan(XFLOAT(num)->data)));
  1680. +   return (make_float (tan((double) XINT(num))));
  1681. + }
  1682. + DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
  1683. +   "Return the hyperbolic tangent of ARG.")
  1684. +   (num)
  1685. +      register Lisp_Object num;
  1686. + {
  1687. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1688. +   if (XTYPE(num) == Lisp_Float)
  1689. +     return (make_float (tanh(XFLOAT(num)->data)));
  1690. +   return (make_float (tanh((double) XINT(num))));
  1691. + }
  1692. + DEFUN ("y0", Fy0, Sy0, 1, 1, 0,
  1693. +   "Return the bessel function y0 of ARG.")
  1694. +   (num)
  1695. +      register Lisp_Object num;
  1696. + {
  1697. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1698. +   if (XTYPE(num) == Lisp_Float)
  1699. +     return (make_float (y0(XFLOAT(num)->data)));
  1700. +   return (make_float (y0((double) XINT(num))));
  1701. + }
  1702. + DEFUN ("y1", Fy1, Sy1, 1, 1, 0,
  1703. +   "Return the bessel function y1 of ARG.")
  1704. +   (num)
  1705. +      register Lisp_Object num;
  1706. + {
  1707. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1708. +   if (XTYPE(num) == Lisp_Float)
  1709. +     return (make_float (y1(XFLOAT(num)->data)));
  1710. +   return (make_float (y1((double) XINT(num))));
  1711. + }
  1712. + DEFUN ("yn", Fyn, Syn, 2, 2, 0,
  1713. + "Return the nth ORDER bessel function output yn of ARG.  First arg is\n\
  1714. + the order of the bessel, and is truncated to an integer.")
  1715. +   (num1, num2)
  1716. +      register Lisp_Object num1, num2;
  1717. + {
  1718. +   int i1;
  1719. +   double f2;
  1720. +   CHECK_NUMBER_OR_FLOAT (num1, 0);
  1721. +   CHECK_NUMBER_OR_FLOAT (num2, 0);
  1722. +   i1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  1723. +   f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  1724. +   return (make_float (yn(i1, f2)));
  1725. + }
  1726. + /* the rounding functions  */
  1727. + DEFUN ("ceiling", Fceiling, Sceiling, 1, 1, 0,
  1728. +   "Return the smallest integer no less than ARG. (round toward +inf)")
  1729. +   (num)
  1730. +      register Lisp_Object num;
  1731. + {
  1732. +   Lisp_Object val = num;
  1733. +      
  1734. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1735. +   if (XTYPE(num) == Lisp_Float)
  1736. +        XSET (val, Lisp_Int, ceil(XFLOAT(num)->data));
  1737. +   return (val);
  1738. + }
  1739. + DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0,
  1740. +        "Return the smallest integral floating pt. number no less than ARG.\n\
  1741. + (round towards +inf)")
  1742. +   (num)
  1743. +      register Lisp_Object num;
  1744. + {
  1745. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1746. +   if (XTYPE(num) == Lisp_Float)
  1747. +     return (make_float (ceil(XFLOAT(num)->data)));
  1748. +   return (make_float ((double) XINT(num)));
  1749. + }
  1750. + DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
  1751. +   "Return the absolute value of ARG.")
  1752. +   (num)
  1753. +      register Lisp_Object num;
  1754. + {
  1755. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1756. +   if (XTYPE(num) == Lisp_Float)
  1757. +     return (make_float (fabs(XFLOAT(num)->data)));
  1758. +   if (XINT(num) < 0)
  1759. +     XSETINT (num, - XFASTINT (num));
  1760. +   return (num);
  1761. + }
  1762. + DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0,
  1763. +        "Return the largest floating pt number no greater than ARG.\n\
  1764. + (round towards -inf)")
  1765. +   (num)
  1766. +      register Lisp_Object num;
  1767. + {
  1768. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1769. +   if (XTYPE(num) == Lisp_Float)
  1770. +     return (make_float (floor(XFLOAT(num)->data)));
  1771. +   return (make_float (floor((double) XINT(num))));
  1772. + }
  1773. + DEFUN ("floor", Ffloor, Sfloor, 1, 1, 0,
  1774. +   "Return the largest integer no greater than ARG. (round towards -inf)")
  1775. +   (num)
  1776. +      register Lisp_Object num;
  1777. + {
  1778. +   Lisp_Object val = num; 
  1779. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1780. +   if (XTYPE(num) == Lisp_Float)
  1781. +     XSET (val, Lisp_Int, floor(XFLOAT(num)->data));
  1782. +   return (val);
  1783. + }
  1784. + DEFUN ("float", Ffloat, Sfloat, 1, 1, 0,
  1785. +   "Return the floating pt. number equal to ARG.")
  1786. +   (num)
  1787. +      register Lisp_Object num;
  1788. + {
  1789. +   Lisp_Object val; 
  1790. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1791. +   if (XTYPE(num) == Lisp_Int)
  1792. +     val = make_float ((double) XINT(num));
  1793. +   else                /* give 'em the same float back */
  1794. +     val = num;
  1795. +   
  1796. +   return (val);
  1797. + }
  1798. + DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
  1799. +   "Return the nearest integral floating pt. number to ARG.")
  1800. +   (num)
  1801. +      register Lisp_Object num;
  1802. + {
  1803. +   CHECK_NUMBER_OR_FLOAT(num, 0);
  1804. +   if (XTYPE(num) == Lisp_Float)
  1805. +     return (make_float (rint(XFLOAT(num)->data)));
  1806. +   return (make_float (rint((double) XINT(num))));
  1807. + }
  1808. + DEFUN ("round", Fround, Sround, 1, 1, 0,
  1809. +   "Return the nearest integer to ARG.")
  1810. +   (num)
  1811. +      register Lisp_Object num;
  1812. + {
  1813. +   Lisp_Object val = num; 
  1814. +   CHECK_NUMBER_OR_FLOAT (num, 0);
  1815. +   if (XTYPE(num) == Lisp_Float)
  1816. +     XSET (val, Lisp_Int, rint(XFLOAT(num)->data));
  1817. +   return (val);
  1818. + }
  1819. + DEFUN ("truncate", Ftruncate, Struncate, 1, 1, 0,
  1820. +        "Truncate a floating point number to an int.\n\
  1821. + (Truncates toward zero.)")
  1822. +   (num)
  1823. +      register Lisp_Object num;
  1824. + {
  1825. +   Lisp_Object val = num;
  1826. +   CHECK_NUMBER_OR_FLOAT(num, 0);
  1827. +   if (XTYPE(num) == Lisp_Float)
  1828. +       XSET (val, Lisp_Int, XFLOAT(num)->data);
  1829. +   return val;
  1830. + }
  1831. + DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
  1832. +        "Truncate a floating point number, returns a float.\n\
  1833. + (Truncates towards zero.) Will fail for floats > max integer.")
  1834. +   (num)
  1835. +      register Lisp_Object num;
  1836. + {
  1837. +   int val;
  1838. +   CHECK_NUMBER_OR_FLOAT(num, 0);
  1839. +   if (XTYPE(num) == Lisp_Float)
  1840. +        val = XFLOAT(num)->data;
  1841. +   else 
  1842. +        val = XINT (num);
  1843. +   return (make_float((double) val));
  1844. + }
  1845. + # ifdef vax
  1846. + /*
  1847. +  * Replacement infnan for 4.3 (vax) math lib.  The original 4.3BSD
  1848. +  * infnan() causes an intentional illegal-instruction and core dump.
  1849. +  * 
  1850. +  * This one is more benign and only signals an error.
  1851. +  */
  1852. + double 
  1853. + infnan(iarg)
  1854. +     int             iarg;
  1855. + {
  1856. +         Fsignal (Qarith_error, Qnil);
  1857. +     /* NOTREACHED */
  1858. +     return (0.0);
  1859. + }
  1860. + # endif vax
  1861. + #endif LISP_FLOAT_TYPE
  1862.   
  1863.   void
  1864.   syms_of_data ()
  1865. ***************
  1866. *** 1353,1358 ****
  1867. --- 2201,2211 ----
  1868.     Qfboundp = intern ("fboundp");
  1869.   
  1870.     Qcdr = intern ("cdr");
  1871. + #ifdef LISP_FLOAT_TYPE
  1872. +   Qfloatp = intern ("floatp");
  1873. +   Qinteger_or_floatp = intern ("integer-or-floatp");
  1874. +   Qinteger_or_float_or_marker_p = intern ("integer-or-float-or-marker-p");
  1875. + #endif LISP_FLOAT_TYPE
  1876.   
  1877.     /* ERROR is used as a signaler for random errors for which nothing else is right */
  1878.   
  1879. ***************
  1880. *** 1476,1481 ****
  1881. --- 2329,2339 ----
  1882.     staticpro (&Qchar_or_string_p);
  1883.     staticpro (&Qmarkerp);
  1884.     staticpro (&Qinteger_or_marker_p);
  1885. + #ifdef LISP_FLOAT_TYPE
  1886. +   staticpro (&Qfloatp);
  1887. +   staticpro (&Qinteger_or_floatp);
  1888. +   staticpro (&Qinteger_or_float_or_marker_p);
  1889. + #endif LISP_FLOAT_TYPE
  1890.     staticpro (&Qboundp);
  1891.     staticpro (&Qfboundp);
  1892.     staticpro (&Qcdr);
  1893. ***************
  1894. *** 1547,1552 ****
  1895. --- 2405,2455 ----
  1896.     defsubr (&Sadd1);
  1897.     defsubr (&Ssub1);
  1898.     defsubr (&Slognot);
  1899. + #ifdef LISP_FLOAT_TYPE
  1900. +   defsubr (&Sfloatp);
  1901. +   defsubr (&Sinteger_or_floatp);
  1902. +   defsubr (&Sinteger_or_float_or_marker_p);
  1903. +   defsubr (&Sacos);
  1904. +   defsubr (&Sacosh);
  1905. +   defsubr (&Sasin);
  1906. +   defsubr (&Sasinh);
  1907. +   defsubr (&Satan);
  1908. +   defsubr (&Satanh);
  1909. +   defsubr (&Scube_root);
  1910. +   defsubr (&Scos);
  1911. +   defsubr (&Scosh);
  1912. +   defsubr (&Serf);
  1913. +   defsubr (&Serfc);
  1914. +   defsubr (&Sexp);
  1915. +   defsubr (&Sexpm1);
  1916. +   defsubr (&Sj0);
  1917. +   defsubr (&Sj1);
  1918. +   defsubr (&Sjn);
  1919. +   defsubr (&Slog_gamma);
  1920. +   defsubr (&Slog);
  1921. +   defsubr (&Slog10);
  1922. +   defsubr (&Slog1p);
  1923. +   defsubr (&Sexpt);
  1924. +   defsubr (&Ssin);
  1925. +   defsubr (&Ssinh);
  1926. +   defsubr (&Ssqrt);
  1927. +   defsubr (&Stan);
  1928. +   defsubr (&Stanh);
  1929. +   defsubr (&Sy0);
  1930. +   defsubr (&Sy1);
  1931. +   defsubr (&Syn);
  1932. +   defsubr (&Sceiling);
  1933. +   defsubr (&Sabs);
  1934. +   defsubr (&Sfloor);
  1935. +   defsubr (&Sfloat);
  1936. +   defsubr (&Sround);
  1937. +   defsubr (&Struncate);
  1938. +   defsubr (&Sfceiling);
  1939. +   defsubr (&Sffloor);
  1940. +   defsubr (&Sfround);
  1941. +   defsubr (&Sftruncate);
  1942. +   defsubr (&Slogb);
  1943. + #endif LISP_FLOAT_TYPE
  1944.   }
  1945.   
  1946.   arith_error (signo)
  1947. diff -rc emacs-18.57/src/lisp.h emacs/src/lisp.h
  1948. *** emacs-18.57/src/lisp.h    Tue Jan  8 18:51:28 1991
  1949. --- emacs/src/lisp.h    Tue Aug 13 10:51:53 1991
  1950. ***************
  1951. *** 1,3 ****
  1952. --- 1,15 ----
  1953. + /******************************************************************************
  1954. + *                                          *
  1955. + *    File:     lisp.h                              *
  1956. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  1957. + *    Created:  Mon Nov  2 15:19:17 EST 1987                      *
  1958. + *    Contents: gnuemacs lisp.h with float code                  *
  1959. + *                                          *
  1960. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  1961. + *    All rights reserved.                              *
  1962. + *                                          *
  1963. + *    $Log$                                      *
  1964. + ******************************************************************************/
  1965.   /* Fundamental definitions for GNU Emacs Lisp interpreter.
  1966.      Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
  1967.   
  1968. ***************
  1969. *** 149,156 ****
  1970. --- 161,174 ----
  1971.          Data inside looks like a Lisp_Vector.  */
  1972.       Lisp_Window,
  1973.   
  1974. + #ifdef LISP_FLOAT_TYPE
  1975. +     /* optional Lisp floating point data type -wolfgang 10/24/87 */
  1976. +     Lisp_Float,
  1977. + #endif LISP_FLOAT_TYPE
  1978.       /* Used by save,set,restore-window-configuration */
  1979.       Lisp_Window_Configuration
  1980.     };
  1981.   
  1982.   #ifndef NO_UNION_TYPE
  1983. ***************
  1984. *** 402,407 ****
  1985. --- 420,429 ----
  1986.   #define XWINDOW(a) ((struct window *) XPNTR(a))
  1987.   #define XPROCESS(a) ((struct Lisp_Process *) XPNTR(a))
  1988.   
  1989. + #ifdef LISP_FLOAT_TYPE
  1990. + # define XFLOAT(a) ((struct Lisp_Float *) XPNTR(a))
  1991. + #endif LISP_FLOAT_TYPE
  1992.   #define XSETCONS(a, b) XSETPNTR(a, (int) (b))
  1993.   #define XSETBUFFER(a, b) XSETPNTR(a, (int) (b))
  1994.   #define XSETVECTOR(a, b) XSETPNTR(a, (int) (b))
  1995. ***************
  1996. *** 414,419 ****
  1997. --- 436,444 ----
  1998.   #define XSETINTPTR(a, b) XSETPNTR(a, (int) (b))
  1999.   #define XSETWINDOW(a, b) XSETPNTR(a, (int) (b))
  2000.   #define XSETPROCESS(a, b) XSETPNTR(a, (int) (b))
  2001. + #ifdef LISP_FLOAT_TYPE
  2002. + # define XSETFLOAT(a, b) XSETPNTR(a, (int) (b))
  2003. + #endif LISP_FLOAT_TYPE
  2004.   
  2005.   /* In a cons, the markbit of the car is the gc mark bit */
  2006.   
  2007. ***************
  2008. *** 475,480 ****
  2009. --- 500,515 ----
  2010.       Lisp_Object chain;
  2011.       int bufpos;
  2012.     };
  2013. + #ifdef LISP_FLOAT_TYPE
  2014. + /* optional Lisp floating point type */
  2015. + struct Lisp_Float
  2016. +    {
  2017. +      Lisp_Object type;        /* essentially used for mark-bit 
  2018. +                    and chaining when on free-list */
  2019. +      double data;  
  2020. +    };
  2021. + #endif LISP_FLOAT_TYPE
  2022.   
  2023.   /* Data type checking */
  2024.   
  2025. ***************
  2026. *** 520,525 ****
  2027. --- 555,572 ----
  2028.     { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
  2029.       else if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qinteger_or_marker_p, (x)); }
  2030.   
  2031. + #ifdef LISP_FLOAT_TYPE
  2032. + #define CHECK_FLOAT(x, i) \
  2033. +   { if (XTYPE ((x)) != Lisp_Float) x = wrong_type_argument (Qfloatp, (x)); }
  2034. + #define CHECK_NUMBER_OR_FLOAT(x, i) \
  2035. + { if ((XTYPE ((x)) != Lisp_Float) && (XTYPE ((x)) != Lisp_Int))\
  2036. +     x = wrong_type_argument (Qinteger_or_floatp, (x)); }
  2037. + #define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x, i) \
  2038. +   { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
  2039. +   else if ((XTYPE ((x)) != Lisp_Int) && (XTYPE ((x)) != Lisp_Float)) \
  2040. +     x = wrong_type_argument (Qinteger_or_float_or_marker_p, (x)); }
  2041. + #endif LISP_FLOAT_TYPE
  2042.   #ifdef VIRT_ADDR_VARIES
  2043.   
  2044.   /* For machines like APOLLO where text and data can go anywhere
  2045. ***************
  2046. *** 762,772 ****
  2047. --- 809,827 ----
  2048.   extern Lisp_Object Qinteger_or_marker_p, Qboundp, Qfboundp;
  2049.   extern Lisp_Object Qcdr;
  2050.   
  2051. + #ifdef LISP_FLOAT_TYPE
  2052. + extern Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
  2053. + #endif LISP_FLOAT_TYPE
  2054.   extern Lisp_Object Feq (), Fnull (), Flistp (), Fconsp (), Fatom (), Fnlistp ();
  2055.   extern Lisp_Object Fintegerp (), Fnatnump (), Fsymbolp ();
  2056.   extern Lisp_Object Fvectorp (), Fstringp (), Farrayp (), Fsequencep ();
  2057.   extern Lisp_Object Fbufferp (), Fmarkerp (), Fsubrp (), Fchar_or_string_p ();
  2058.   extern Lisp_Object Finteger_or_marker_p ();
  2059. + #ifdef LISP_FLOAT_TYPE
  2060. + extern Lisp_Object Ffloatp(), Finteger_or_floatp(),
  2061. +   Finteger_or_float_or_marker_p(), Ftruncate();
  2062. + #endif LISP_FLOAT_TYPE
  2063.   
  2064.   extern Lisp_Object Fcar (), Fcar_safe(), Fcdr (), Fcdr_safe();
  2065.   extern Lisp_Object Fsetcar (), Fsetcdr ();
  2066. ***************
  2067. *** 788,793 ****
  2068. --- 843,852 ----
  2069.   extern void args_out_of_range ();
  2070.   extern void args_out_of_range_3 ();
  2071.   extern Lisp_Object wrong_type_argument ();
  2072. + #ifdef LISP_FLOAT_TYPE
  2073. + extern Lisp_Object Ffloat_to_int(), Fint_to_float();
  2074. + #endif LISP_FLOAT_TYPE
  2075.   
  2076.   /* Defined in fns.c */
  2077.   extern Lisp_Object Qstring_lessp;
  2078. diff -rc emacs-18.57/src/lread.c emacs/src/lread.c
  2079. *** emacs-18.57/src/lread.c    Tue Jan  8 18:52:01 1991
  2080. --- emacs/src/lread.c    Tue Aug 13 10:52:06 1991
  2081. ***************
  2082. *** 1,3 ****
  2083. --- 1,15 ----
  2084. + /******************************************************************************
  2085. + *                                          *
  2086. + *    File:     lread.c                              *
  2087. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  2088. + *    Created:  Mon Nov  2 15:23:48 EST 1987                      *
  2089. + *    Contents: GNU lread.c with my float code                  *
  2090. + *                                          *
  2091. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  2092. + *    All rights reserved.                              *
  2093. + *                                          *
  2094. + *    $Log$                                      *
  2095. + ******************************************************************************/
  2096.   /* Lisp parsing and input streams.
  2097.      Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
  2098.   
  2099. ***************
  2100. *** 39,44 ****
  2101. --- 51,60 ----
  2102.   #define X_OK 01
  2103.   #endif
  2104.   
  2105. + #ifdef LISP_FLOAT_TYPE
  2106. + #include <math.h>
  2107. + #endif LISP_FLOAT_TYPE
  2108.   Lisp_Object Qread_char, Qget_file_char, Qstandard_input;
  2109.   Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input;
  2110.   
  2111. ***************
  2112. *** 661,670 ****
  2113.   
  2114.         while (c > 040 && 
  2115.            !(c == '\"' || c == '\'' || c == ';' || c == '?'
  2116. !            || c == '(' || c == ')' || c =='.'
  2117.              || c == '[' || c == ']' || c == '#'
  2118.              ))
  2119.           {
  2120.             if (p == end)
  2121.           {
  2122.             register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  2123. --- 677,699 ----
  2124.   
  2125.         while (c > 040 && 
  2126.            !(c == '\"' || c == '\'' || c == ';' || c == '?'
  2127. !            || c == '(' || c == ')'
  2128. ! #ifndef LISP_FLOAT_TYPE        /* we need to see <number><dot><number> */
  2129. !            || c =='.'
  2130. ! #endif not LISP_FLOAT_TYPE
  2131.              || c == '[' || c == ']' || c == '#'
  2132.              ))
  2133.           {
  2134. + #ifdef LISP_FLOAT_TYPE_nuked    /* for added robustness */
  2135. +           if (c == '.')
  2136. +         {        /* fix up dotted pair stuff */
  2137. +           if (((p - 1) < read_buffer) ||
  2138. +               ((*(p-1)) < '0') ||
  2139. +               ((*(p-1)) > '9'))
  2140. +             break;    /* wasn't <numeric-string><dot> */
  2141. +         }
  2142. + #endif LISP_FLOAT_TYPE
  2143.             if (p == end)
  2144.           {
  2145.             register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  2146. ***************
  2147. *** 705,716 ****
  2148.             return val;
  2149.           }
  2150.           }
  2151.       }
  2152.       return intern (read_buffer);
  2153.         }
  2154.       }
  2155.   }
  2156.   
  2157.   static Lisp_Object
  2158.   read_vector (readcharfun)
  2159. --- 734,801 ----
  2160.             return val;
  2161.           }
  2162.           }
  2163. +       if (isfloat_string (read_buffer))
  2164. +         return make_float (atof(read_buffer));
  2165.       }
  2166.       return intern (read_buffer);
  2167.         }
  2168.       }
  2169.   }
  2170. + #ifdef LISP_FLOAT_TYPE
  2171. + #include <ctype.h>
  2172. + #define LEAD_INT 1
  2173. + #define DOT_CHAR 2
  2174. + #define TRAIL_INT 4
  2175. + #define E_CHAR 8
  2176. + #define EXP_INT 16
  2177. + isfloat_string(cp)
  2178. +      register char *cp;
  2179. + {
  2180. +   register state;
  2181. +   
  2182. +   state = 0;
  2183. +   if ((*cp == '+') || (*cp == '-'))
  2184. +     cp++;
  2185. +   if (isdigit(*cp))
  2186. +     {
  2187. +       state |= LEAD_INT;
  2188. +       while (isdigit (*cp))
  2189. +     cp ++;
  2190. +     }
  2191. +   if (*cp == '.')
  2192. +     {
  2193. +       state |= DOT_CHAR;
  2194. +       cp++;
  2195. +     }
  2196. +   if (isdigit(*cp))
  2197. +     {
  2198. +       state |= TRAIL_INT;
  2199. +       while (isdigit (*cp))
  2200. +     cp++;
  2201. +     }
  2202. +   if (*cp == 'e')
  2203. +     {
  2204. +       state |= E_CHAR;
  2205. +       cp++;
  2206. +     }
  2207. +   if ((*cp == '+') || (*cp == '-'))
  2208. +     {
  2209. +       cp++;
  2210. +     }
  2211. +   if (isdigit(*cp))
  2212. +     {
  2213. +       state |= EXP_INT;
  2214. +       while (isdigit (*cp))
  2215. +     cp++;
  2216. +     }
  2217. +   return ((*cp == 0) &&
  2218. +       ((state == (LEAD_INT|DOT_CHAR|TRAIL_INT)) ||
  2219. +        (state == (LEAD_INT|E_CHAR|EXP_INT)) ||
  2220. +        (state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))));
  2221. + }
  2222. + #endif LISP_FLOAT_TYPE
  2223.   
  2224.   static Lisp_Object
  2225.   read_vector (readcharfun)
  2226. diff -rc emacs-18.57/src/m-sun3.h emacs/src/m-sun3.h
  2227. *** emacs-18.57/src/m-sun3.h    Wed Jun 20 18:42:45 1990
  2228. --- emacs/src/m-sun3.h    Tue Aug 13 10:52:12 1991
  2229. ***************
  2230. *** 14,19 ****
  2231. --- 14,22 ----
  2232.   #define A_TEXT_OFFSET(HDR) sizeof (HDR)
  2233.   
  2234.   /* In case we are using floating point, work together with crt0.c.  */
  2235. + #define C_SWITCH_MACHINE -fsoft
  2236. + /* In case we are using floating point, work together with crt0.c.  */
  2237.   
  2238.   #ifndef __GNUC__
  2239.   #define C_SWITCH_MACHINE -fsoft
  2240. diff -rc emacs-18.57/src/print.c emacs/src/print.c
  2241. *** emacs-18.57/src/print.c    Tue Jan  8 19:01:11 1991
  2242. --- emacs/src/print.c    Tue Aug 13 10:52:18 1991
  2243. ***************
  2244. *** 1,3 ****
  2245. --- 1,15 ----
  2246. + /******************************************************************************
  2247. + *                                          *
  2248. + *    File:     print.c                              *
  2249. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  2250. + *    Created:  Mon Nov  2 15:24:52 EST 1987                      *
  2251. + *    Contents: GNU print.c with my float code                  *
  2252. + *                                          *
  2253. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  2254. + *    All rights reserved.                              *
  2255. + *                                          *
  2256. + *    $Log$                                      *
  2257. + ******************************************************************************/
  2258.   /* Lisp object printing and output streams.
  2259.      Copyright (C) 1985, 1986, 1990 Free Software Foundation, Inc.
  2260.   
  2261. ***************
  2262. *** 33,38 ****
  2263. --- 45,55 ----
  2264.   
  2265.   Lisp_Object Vstandard_output, Qstandard_output;
  2266.   
  2267. + #ifdef LISP_FLOAT_TYPE
  2268. + Lisp_Object Vfloat_output_format,Qfloat_output_format;
  2269. + #endif LISP_FLOAT_TYPE
  2270.   /* Avoid actual stack overflow in print.  */
  2271.   int print_depth;
  2272.   
  2273. ***************
  2274. *** 440,445 ****
  2275. --- 457,540 ----
  2276.     return obj;
  2277.   }
  2278.   
  2279. + #ifdef LISP_FLOAT_TYPE
  2280. + #define WFLAG 0x80
  2281. + #define FIXBOUNDS(x,l,u) { if (x < l) {x = l;} else if (x > u) {x = u;}}
  2282. + void
  2283. +   float_to_string (buf, data)
  2284. + char * buf;
  2285. + /*
  2286. +  * This buffer should be at least as large as the max string size of the
  2287. +  * largest float, printed in the biggest notation.  This is undoubtably
  2288. +  * 20d float_output_format, with the negative of the C-constant "HUGE"
  2289. +  * from <math.h>.
  2290. +  * 
  2291. +  * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
  2292. +  * 
  2293. +  * I assume that IEEE-754 format numbers can take 329 bytes for the worst
  2294. +  * case of -1e307 in 20d float_output_format. What is one to do (short of
  2295. +  * re-writing _doprnt to be more sane)?
  2296. +  *             -wsr
  2297. +  */
  2298. + double data;
  2299. + {
  2300. +   register unsigned char *cp, c, *endp;
  2301. +   register int width;
  2302. +   unsigned int state;
  2303. +       
  2304. +   if (NULL (Vfloat_output_format) ||
  2305. +       (XTYPE(Vfloat_output_format) != Lisp_String))
  2306. +     sprintf (buf, "%.2e", data);
  2307. +   else            /* oink oink */
  2308. +     {
  2309. +       cp = XSTRING(Vfloat_output_format)->data;
  2310. +       endp = XSTRING(Vfloat_output_format)->size + cp;
  2311. +       state = 0;
  2312. +       
  2313. +       for (width = 0;
  2314. +        ((cp < endp) && ((c = *cp) >= '0') && (c <= '9'));
  2315. +        cp++)
  2316. +     {
  2317. +       state = WFLAG;
  2318. +       width *= 10;
  2319. +       width += c - '0';
  2320. +     }
  2321. +       
  2322. +       if ((cp < endp) &&
  2323. +       ((c = *cp) == 'e') || (c == 'd'))
  2324. +     state |= c;
  2325. +       
  2326. +       switch (state)
  2327. +     {
  2328. +     default:        /* never happen ... */
  2329. +     case 0:
  2330. +       sprintf (buf, "%.3g", data);
  2331. +       break;
  2332. +     case WFLAG:
  2333. +       FIXBOUNDS(width, 1, 20);
  2334. +       sprintf (buf, "%.*g", width, data);
  2335. +       break;
  2336. +     case 'e':
  2337. +       sprintf (buf, "%.2e", data);
  2338. +       break;
  2339. +     case 'e'|WFLAG:
  2340. +       FIXBOUNDS(width, 0, 20);
  2341. +       sprintf (buf, "%.*e", width, data);
  2342. +       break;
  2343. +     case 'd':
  2344. +       sprintf (buf, "%.3f", data);
  2345. +       break;
  2346. +     case 'd'|WFLAG:
  2347. +       FIXBOUNDS(width, 1, 20);
  2348. +       sprintf (buf, "%.*f", width, data);
  2349. +       break;
  2350. +     }
  2351. +     }
  2352. + }
  2353. + #endif LISP_FLOAT_TYPE
  2354.   static void
  2355.   print (obj, printcharfun, escapeflag)
  2356.   #ifndef RTPC_REGISTER_BUG
  2357. ***************
  2358. *** 481,486 ****
  2359. --- 576,592 ----
  2360.             -1, printcharfun);
  2361.         break;
  2362.   
  2363. + #ifdef LISP_FLOAT_TYPE
  2364. +     case Lisp_Float:
  2365. +       {
  2366. +     char pigbuf[350];    /* see comments in float_to_string */
  2367. +     float_to_string (pigbuf, XFLOAT(obj)->data);
  2368. +     strout (pigbuf, -1, printcharfun);
  2369. +       }
  2370. +       break;
  2371. + #endif LISP_FLOAT_TYPE
  2372.       case Lisp_Int:
  2373.         sprintf (buf, "%d", XINT (obj));
  2374.         strout (buf, -1, printcharfun);
  2375. ***************
  2376. *** 673,678 ****
  2377. --- 779,809 ----
  2378.     Vstandard_output = Qt;
  2379.     Qstandard_output = intern ("standard-output");
  2380.     staticpro (&Qstandard_output);
  2381. + #ifdef LISP_FLOAT_TYPE
  2382. +   DEFVAR_LISP ("float-output-format", &Vfloat_output_format,
  2383. + "The format descriptor string (or nil) that lisp uses to print out\n\
  2384. + floats. Nil means use built-in defaults.\n\
  2385. + The descriptor string consists of an optional field-width spec,\n\
  2386. + followed by an optional output-style descriptor.\n\
  2387. + \n\
  2388. + Valid field-widths specs are:\n\
  2389. + The empty string for default precision.\n\
  2390. + 0-20 for exponential notation, or 1-20 for decimal point notation. A 0\n\
  2391. + field spec causes the printing of the decimal point to be supressed.\n\
  2392. + Using an out of bounds specs cause the closest valid spec to be used.\n\
  2393. + \n\
  2394. + Valid ouput-styles may be one of the following:\n\
  2395. + The letter 'e' for exponential notation \"<number>.<number>e<number>\"\n\
  2396. + The letter 'd' for decimal point notation \"<number>.<number>\".\n\
  2397. + The empty string, for the defaulted output style.  This may print in\n\
  2398. + either format in a data-dependent manner, choosing whatever produces\n\
  2399. + the shortest string.\n\
  2400. + ");
  2401. +   Vfloat_output_format = Qnil;
  2402. +   Qfloat_output_format = intern ("float-output-format");
  2403. +   staticpro (&Qfloat_output_format);
  2404. + #endif LISP_FLOAT_TYPE
  2405.   
  2406.     DEFVAR_LISP ("print-length", &Vprint_length,
  2407.       "Maximum length of list to print before abbreviating.\
  2408. diff -rc emacs-18.57/src/ymakefile emacs/src/ymakefile
  2409. *** emacs-18.57/src/ymakefile    Tue Jan  8 19:23:01 1991
  2410. --- emacs/src/ymakefile    Tue Aug 13 11:47:39 1991
  2411. ***************
  2412. *** 1,3 ****
  2413. --- 1,15 ----
  2414. + /******************************************************************************
  2415. + *                                          *
  2416. + *    File:     ymakefile                              *
  2417. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  2418. + *    Created:  Mon Nov  2 15:27:47 EST 1987                      *
  2419. + *    Contents: GNU ymakefile with my float code                  *
  2420. + *                                          *
  2421. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  2422. + *    All rights reserved.                              *
  2423. + *                                          *
  2424. + *    $Log$                                      *
  2425. + ******************************************************************************/
  2426.   /* Makefile for GNU Emacs.
  2427.      Copyright (C) 1985, 1987, 1988, 1990 Free Software Foundation, Inc.
  2428.   
  2429. ***************
  2430. *** 62,67 ****
  2431. --- 74,88 ----
  2432.   #define LIBS_MACHINE
  2433.   #endif
  2434.   
  2435. + #ifndef LIB_MATH
  2436. + # ifdef LISP_FLOAT_TYPE
  2437. + #  define LIB_MATH -lm
  2438. + # else 
  2439. + #  define LIB_MATH
  2440. + # endif
  2441. + #endif
  2442.   /* Some s- files define this to request special switches in ld.  */
  2443.   #ifndef LD_SWITCH_SYSTEM
  2444.   #if defined (BSD) && !defined (COFF)
  2445. ***************
  2446. *** 144,150 ****
  2447.   SHORT= shortnames
  2448.   #endif /* SHORTNAMES */
  2449.   
  2450. ! CFLAGS= C_DEBUG_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM
  2451.   /* DO NOT use -R.  There is a special hack described in lastfile.c
  2452.      which is used instead.  Some initialized data areas are modified
  2453.      at initial startup, then labeled as part of the text area when
  2454. --- 165,171 ----
  2455.   SHORT= shortnames
  2456.   #endif /* SHORTNAMES */
  2457.   
  2458. ! CFLAGS= C_OPTIMIZE_SWITCH C_DEBUG_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM
  2459.   /* DO NOT use -R.  There is a special hack described in lastfile.c
  2460.      which is used instead.  Some initialized data areas are modified
  2461.      at initial startup, then labeled as part of the text area when
  2462. ***************
  2463. *** 272,277 ****
  2464. --- 293,301 ----
  2465.       ${lispdir}text-mode.elc ${lispdir}fill.elc \
  2466.       ${lispdir}c-mode.elc ${lispdir}isearch.elc \
  2467.       ${lispdir}replace.elc ${lispdir}abbrev.elc \
  2468. + #ifdef LISP_FLOAT_TYPE
  2469. +     ${lispdir}float-sup.elc \
  2470. + #endif LISP_FLOAT_TYPE
  2471.       ${lispdir}buff-menu.elc ${lispdir}subr.elc
  2472.   
  2473.   /* just to be sure the sh is used */
  2474. ***************
  2475. *** 278,284 ****
  2476.   SHELL=/bin/sh
  2477.   
  2478.   /* Construct full set of libraries to be linked.  */
  2479. ! LIBES = LIBS_TERMCAP $(LIBX) LIBS_SYSTEM LIBS_MACHINE LIBS_DEBUG LIB_STANDARD $(GNULIB_VAR)
  2480.   
  2481.   /* Enable recompilation of certain other files depending on system type.  */
  2482.   
  2483. --- 302,308 ----
  2484.   SHELL=/bin/sh
  2485.   
  2486.   /* Construct full set of libraries to be linked.  */
  2487. ! LIBES = LIBS_TERMCAP $(LIBX) LIBS_SYSTEM LIBS_MACHINE LIBS_DEBUG LIB_MATH LIB_STANDARD $(GNULIB_VAR)
  2488.   
  2489.   /* Enable recompilation of certain other files depending on system type.  */
  2490.