~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/exp-aux.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;-*- Mode:     Lisp -*-
 
2
;;;; Author:   Paul Dietz
 
3
;;;; Created:  Mon Sep  1 21:30:38 2003
 
4
;;;; Contains: Aux. functions for testing EXP, EXPT
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(defun my-exp (x n)
 
9
  "Compute e^x in the appropriate float result type, summing
 
10
   the first n terms of the Taylor series."
 
11
  (assert (realp x))
 
12
  (let ((result 1)
 
13
        (xrat (rational x)))
 
14
    (loop
 
15
     for i from (1- n) downto 1
 
16
     do (setq result (+ 1 (/ (* xrat result) i))))
 
17
    (if (floatp x)
 
18
      (float result x)
 
19
      (float result 1.0f0))))
 
20
 
 
21
 
 
22
    
 
23
 
 
24