<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>
Raymond Toy pushed to branch master
at <a href="https://gitlab.common-lisp.net/cmucl/cmucl">cmucl / cmucl</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/f3b73541a4918c50abdc17da4164113e40fa6036">f3b73541</a></strong>
<div>
<span>by Raymond Toy</span>
<i>at 2016-01-01T09:30:18Z</i>
</div>
<pre class='commit-message'>Add special case for (expt 0 power)
We know the result of (expt 0 power) so return it immediately without
first checking if the power exceeds the limit.
Also took the opportunity to add a better message to the
intexp-limit-error condition to make it more explicit what is being
computed and why it's failing.
Tests added too.</pre>
</li>
</ul>
<h4>2 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/code/irrat.lisp
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
tests/irrat.lisp
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/f3b73541a4918c50abdc17da4164113e40fa6036#diff-0'>
<strong>
src/code/irrat.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/irrat.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/irrat.lisp
</span><span style="color: #aaaaaa">@@ -252,6 +252,13 @@
</span> (return-from intexp base))
(when (eql base -1)
(return-from intexp (if (oddp power) -1 1)))
<span style="color: #000000;background-color: #ddffdd">+
+ ;; Handle 0 raised to a power. Return 0 if the power is
+ ;; non-negative or signal a divide-by-zero if the power is negative.
+ (when (zerop base)
+ (if (minusp power)
+ (error 'division-by-zero)
+ (return-from intexp base)))
</span>
(when (> (abs power) *intexp-maximum-exponent*)
;; Allow user the option to continue with calculation, possibly
</code></pre>
<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/f3b73541a4918c50abdc17da4164113e40fa6036#diff-1'>
<strong>
tests/irrat.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/irrat.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/irrat.lisp
</span><span style="color: #aaaaaa">@@ -152,3 +152,23 @@
</span> for logx = (kernel::dd-%log2 x)
for log1/x = (kernel::dd-%log2 (/ x))
do (assert-true (<= (abs (+ logx log1/x)) (* 1 double-float-epsilon)))))
<span style="color: #000000;background-color: #ddffdd">+
+(define-test expt-integer
+ (let ((power (1+ kernel::*intexp-maximum-exponent*)))
+ ;; Make sure we error out in the usual case with the power too
+ ;; large.
+ (assert-error 'kernel::intexp-limit-error
+ (expt 2 power))
+ (assert-error 'kernel::intexp-limit-error
+ (expt 2 (- power)))
+ ;; But raising 0 or 1 to a power shouldn't signal anything, except
+ ;; the obvious division-by-zero.
+ (assert-eql 1 (expt 1 power))
+ (cond ((evenp power)
+ (assert-eql 1 (expt -1 power))
+ (assert-eql -1 (expt -1 (1+ power))))
+ (t
+ (assert-eql -1 (expt -1 power))
+ (assert-eql 1 (expt -1 (1+ power)))))
+ (assert-eql 0 (expt 0 power))
+ (assert-error 'division-by-zero (expt 0 (- power)))))
</span></code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/f3b73541a4918c50abdc17da4164113e40fa6036">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.common-lisp.net.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.common-lisp.net/cmucl/cmucl/commit/f3b73541a4918c50abdc17da4164113e40fa6036"}}</script>
</p>
</div>
</body>
</html>