Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
59bbdaa0
Commit
59bbdaa0
authored
34 years ago
by
ram
Browse files
Options
Downloads
Patches
Plain Diff
Changed ROUND to call %UNARY-ROUND when the second arg is 1.
parent
c69a379b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/numbers.lisp
+20
-19
20 additions, 19 deletions
code/numbers.lisp
with
20 additions
and
19 deletions
code/numbers.lisp
+
20
−
19
View file @
59bbdaa0
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
;;; Scott Fahlman (FAHLMAN@CMUC).
;;; Scott Fahlman (FAHLMAN@CMUC).
;;; **********************************************************************
;;; **********************************************************************
;;;
;;;
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.1
4
1990/1
0/03 09:58:11 wlott
Exp $
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.1
5
1990/1
2/11 23:59:54 ram
Exp $
;;;
;;;
;;; This file contains the definitions of most number functions.
;;; This file contains the definitions of most number functions.
;;;
;;;
...
@@ -559,7 +559,8 @@
...
@@ -559,7 +559,8 @@
;;; Declare these guys inline to let them get optimized a little. Round and
;;; Declare these guys inline to let them get optimized a little. Round and
;;; Fround are not declared inline since they seem too obscure and too
;;; Fround are not declared inline since they seem too obscure and too
;;; big to inline-expand by default.
;;; big to inline-expand by default. Also, this gives the compiler a chance to
;;; pick off the unary float case.
;;;
;;;
(
proclaim
'
(
inline
ceiling
floor
rem
mod
fceiling
ffloor
ftruncate
))
(
proclaim
'
(
inline
ceiling
floor
rem
mod
fceiling
ffloor
ftruncate
))
...
@@ -595,25 +596,25 @@
...
@@ -595,25 +596,25 @@
(
values
tru
rem
))))
(
values
tru
rem
))))
(
defun
round
(
number
&optional
(
divisor
1
)
&aux
thresh
)
(
defun
round
(
number
&optional
(
divisor
1
))
"Rounds number (or number/divisor) to nearest integer.
"Rounds number (or number/divisor) to nearest integer.
The second returned value is the remainder."
The second returned value is the remainder."
(
multiple-value-bind
(
tru
rem
)
(
truncate
number
divisor
)
(
if
(
eql
divisor
1
)
(
if
(
eql
divisor
1
)
(
round
number
)
(
setq
thresh
0.5
)
(
multiple-value-bind
(
tru
rem
)
(
truncate
number
divisor
)
(
s
et
q
thresh
(
/
(
abs
divisor
)
2
)))
(
l
et
((
thresh
(
/
(
abs
divisor
)
2
)))
(
cond
((
or
(
>
rem
thresh
)
(
cond
((
or
(
>
rem
thresh
)
(
and
(
=
rem
thresh
)
(
oddp
tru
)))
(
and
(
=
rem
thresh
)
(
oddp
tru
)))
(
if
(
minusp
divisor
)
(
if
(
minusp
divisor
)
(
values
(
-
tru
1
)
(
+
rem
divisor
))
(
values
(
-
tru
1
)
(
+
rem
divisor
))
(
values
(
+
tru
1
)
(
-
rem
divisor
))))
(
values
(
+
tru
1
)
(
-
rem
divisor
))))
((
let
((
-thresh
(
-
thresh
)))
((
let
((
-thresh
(
-
thresh
)))
(
or
(
<
rem
-thresh
)
(
or
(
<
rem
-thresh
)
(
and
(
=
rem
-thresh
)
(
oddp
tru
))))
(
and
(
=
rem
-thresh
)
(
oddp
tru
))))
(
if
(
minusp
divisor
)
(
if
(
minusp
divisor
)
(
values
(
+
tru
1
)
(
-
rem
divisor
))
(
values
(
+
tru
1
)
(
-
rem
divisor
))
(
values
(
-
tru
1
)
(
+
rem
divisor
))))
(
values
(
-
tru
1
)
(
+
rem
divisor
))))
(
t
(
values
tru
rem
)))))
(
t
(
values
tru
rem
)))))
))
(
defun
rem
(
number
divisor
)
(
defun
rem
(
number
divisor
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment