Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
b4739e5d
Commit
b4739e5d
authored
Jul 04, 2007
by
Jay Belanger
Browse files
(calculator-expt): Use more cases to determine the value.
parent
aa9f2751
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
lisp/ChangeLog
lisp/ChangeLog
+5
-0
lisp/calculator.el
lisp/calculator.el
+22
-8
No files found.
lisp/ChangeLog
View file @
b4739e5d
2007-07-04 Jay Belanger <jay.p.belanger@gmail.com>
* calculator.el (calculator-expt): Use more cases to determine
the value.
2007-07-03 Jay Belanger <jay.p.belanger@gmail.com>
* calculator.el (calculator-expt, calculator-integer-p):
...
...
lisp/calculator.el
View file @
b4739e5d
...
...
@@ -1793,14 +1793,28 @@ To use this, apply a binary operator (evaluate it), then call this."
(
expt
x
y
)
(
domain-error
0.0e+NaN
)
(
range-error
(
if
(
>
y
0
)
(
if
(
and
(
<
x
0
)
(
=
y
(
truncate
y
))
(
oddp
(
truncate
y
)))
-1.0e+INF
1.0e+INF
)
0.0
))
(
cond
((
and
(
<
x
1.0
)
(
>
x
-1.0
))
;; For small x, the range error comes from large y.
0.0
)
((
and
(
>
x
0.0
)
(
<
y
0.0
))
;; For large positive x and negative y, the range error
;; comes from large negative y.
0.0
)
((
and
(
>
x
0.0
)
(
>
y
0.0
))
;; For large positive x and positive y, the range error
;; comes from large y.
1.0e+INF
)
;; For the rest, x must be large and negative.
;; The range errors come from large integer y.
((
<
y
0.0
)
0.0
)
((
oddp
(
truncate
y
))
;; If y is odd
-1.0e+INF
)
(
t
;;
1.0e+INF
)))
(
error
0.0e+NaN
)))
(
defun
calculator-fact
(
x
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment