Raymond Toy pushed to branch issue-293-restart-on-reader-fp-overflow at cmucl / cmucl
Commits:
da48651d by Raymond Toy at 2024-04-10T14:28:16-07:00
Add issue #293 to release notes.
- - - - -
1 changed file:
- src/general-info/release-21f.md
Changes:
=====================================
src/general-info/release-21f.md
=====================================
@@ -65,6 +65,7 @@ public domain.
* ~~#288~~ Re-enable `deftransform` for random integers.
* ~~#290~~ Pprint `with-float-traps-masked` better
* ~~#291~~ Pprint `handler-case` neatly.
+ * ~~#293~~ Allow restarts for FP overflow in reader.
* ~~#297~~ Pprint `new-assem:assemble` with less indentation.
* Other changes:
* Improvements to the PCL implementation of CLOS:
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/da48651df72c0685a095cca…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/da48651df72c0685a095cca…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-275b-signal-float-underflow at cmucl / cmucl
Commits:
6b933b4a by Raymond Toy at 2024-04-10T14:26:39-07:00
Add issue #275 to release notes.
- - - - -
1 changed file:
- src/general-info/release-21f.md
Changes:
=====================================
src/general-info/release-21f.md
=====================================
@@ -56,6 +56,7 @@ public domain.
* ~~#271~~ Update ASDF to 3.3.7
* ~~#272~~ Move scavenge code for static vectors to its own function
* ~~#274~~ 1d99999999 hangs
+ * ~~#275~~ FP underflow in reader allows restarting with 0
* ~~#276~~ Implement xoroshiro128** generator for x86
* ~~#277~~ `float-ratio-float` returns 0 for numbers close to
least-positive-float
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/6b933b4a49b664564b45b28…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/6b933b4a49b664564b45b28…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-275b-signal-float-underflow at cmucl / cmucl
Commits:
f3b2f7d8 by Raymond Toy at 2024-04-10T08:12:12-07:00
Add test reading denormals with underflow enabled.
We should be able to read denormals without problems even if FP
underflow is enabled.
- - - - -
e27ac073 by Raymond Toy at 2024-04-10T13:08:05-07:00
Fix underflow test that was underflowing
In the test, we had underflow enabled, but computed numbers that would
underflow. Hence, only wrap the part that reads floats with underflow
enabled.
- - - - -
1e3a49ea by Raymond Toy at 2024-04-10T13:10:29-07:00
Just enable underflow only around reading from the string
- - - - -
3f4072b5 by Raymond Toy at 2024-04-10T13:11:16-07:00
Handle underflow for very tiny numbers
Previously, when the numbers were very tiny, we signaled a
reader-error but didn't have a restart to return 0. Modify the code
so that when we have very tiny numbers, we signal a
`floating-point-underflow` error that we can catch and establish a
restart to return 0.
For very large numbers that overflow, we just signal a reader-error
for now.
Update cmucl.pot too for the new string.
- - - - -
3 changed files:
- src/code/reader.lisp
- src/i18n/locale/cmucl.pot
- tests/float.lisp
Changes:
=====================================
src/code/reader.lisp
=====================================
@@ -1832,67 +1832,70 @@ the end of the stream."
;; throw an error immediately. We don't need to be super accurate
;; with the limits. The rest of the code will handle it correctly,
;; even if we're too small or too large.
- (unless (zerop number)
- (flet ((fast-log2 (n)
- ;; For an integer, the integer-length is close enough to
- ;; the log2 of the number.
- (integer-length n)))
- ;; log2(x) = log(number*10^exponent/divisor)
- ;; = exponent*log2(10) + log2(number)-log2(divisor)
- (let ((log2-num (+ (* exponent #.(kernel::log2 10d0))
- (fast-log2 number)
- (- (fast-log2 divisor)))))
- (multiple-value-bind (log2-low log2-high)
- (ecase float-format
- ((short-float single-float)
- ;; Single-float exponents range is -149 to 127, but we
- ;; don't need to be super-accurate since we're
- ;; multiplying the values by 2.
- (values (* 2 (- vm:single-float-normal-exponent-min
- vm:single-float-bias
- vm:single-float-digits))
- (* 2 (- vm:single-float-normal-exponent-max
- vm:single-float-bias))))
- ((double-float long-float
- #+double-double kernel:double-double-float)
- ;; Double-float exponent range is -1074 to -1023
- (values (* 2 (- vm:double-float-normal-exponent-min
- vm:double-float-bias
- vm:double-float-digits))
- (* 2 (- vm:double-float-normal-exponent-max
- vm:double-float-bias)))))
- (unless (< log2-low log2-num log2-high)
- ;; The number is definitely too large or too small to fit.
- ;; Signal an error.
- (%reader-error stream _"Number not representable as a ~S: ~S"
- float-format (read-buffer-to-string)))))))
-
- ;; Otherwise the number might fit, so we carefully compute the result.
- (handler-case
- (with-float-traps-masked (:underflow)
- (let* ((ratio (/ (* (expt 10 exponent) number)
- divisor))
- (result (coerce ratio float-format)))
- (when (and (zerop result) (not (zerop number)))
- ;; The number we've read is so small that it gets
- ;; converted to 0.0, but is not actually zero. Signal an
- ;; error. See CLHS 2.3.1.1.
- (error 'floating-point-underflow))
- result))
- (floating-point-underflow ()
- ;; Resignal a reader error, but allow the user to continue with
- ;; 0.
- (let ((zero (coerce 0 float-format)))
- (restart-case
- (%reader-error stream _"Floating point underflow when reading ~S: ~S"
- float-format (read-buffer-to-string))
- (continue ()
- :report (lambda (stream)
- (format stream "Return ~A" zero))
- zero))))
- (error ()
- (%reader-error stream _"Number not representable as a ~S: ~S"
- float-format (read-buffer-to-string)))))
+ (flet ((handle-extreme-numbers ()
+ (unless (zerop number)
+ (flet ((fast-log2 (n)
+ ;; For an integer, the integer-length is close enough to
+ ;; the log2 of the number.
+ (integer-length n)))
+ ;; log2(x) = log(number*10^exponent/divisor)
+ ;; = exponent*log2(10) + log2(number)-log2(divisor)
+ (let ((log2-num (+ (* exponent #.(kernel::log2 10d0))
+ (fast-log2 number)
+ (- (fast-log2 divisor)))))
+ (multiple-value-bind (log2-low log2-high)
+ (ecase float-format
+ ((short-float single-float)
+ ;; Single-float exponents range is -149 to 127, but we
+ ;; don't need to be super-accurate since we're
+ ;; multiplying the values by 2.
+ (values (* 2 (- vm:single-float-normal-exponent-min
+ vm:single-float-bias
+ vm:single-float-digits))
+ (* 2 (- vm:single-float-normal-exponent-max
+ vm:single-float-bias))))
+ ((double-float long-float
+ #+double-double kernel:double-double-float)
+ ;; Double-float exponent range is -1074 to -1023
+ (values (* 2 (- vm:double-float-normal-exponent-min
+ vm:double-float-bias
+ vm:double-float-digits))
+ (* 2 (- vm:double-float-normal-exponent-max
+ vm:double-float-bias)))))
+ (when (<= log2-num log2-low)
+ ;; Number is definitely too small; signal an underflow.
+ (error 'floating-point-underflow))
+ (when (>= log2-num log2-high)
+ ;; Number is definitely too large; signal an error
+ (error "Overflow"))))))))
+
+ ;; Otherwise the number might fit, so we carefully compute the result.
+ (handler-case
+ (with-float-traps-masked (:underflow)
+ (handle-extreme-numbers)
+ (let* ((ratio (/ (* (expt 10 exponent) number)
+ divisor))
+ (result (coerce ratio float-format)))
+ (when (and (zerop result) (not (zerop number)))
+ ;; The number we've read is so small that it gets
+ ;; converted to 0.0, but is not actually zero. Signal an
+ ;; error. See CLHS 2.3.1.1.
+ (error 'floating-point-underflow))
+ result))
+ (floating-point-underflow ()
+ ;; Resignal a reader error, but allow the user to continue with
+ ;; 0.
+ (let ((zero (coerce 0 float-format)))
+ (restart-case
+ (%reader-error stream _"Floating point underflow when reading ~S: ~S"
+ float-format (read-buffer-to-string))
+ (continue ()
+ :report (lambda (stream)
+ (format stream "Return ~A" zero))
+ zero))))
+ (error ()
+ (%reader-error stream _"Number not representable as a ~S: ~S"
+ float-format (read-buffer-to-string))))))
(defun make-ratio (stream)
=====================================
src/i18n/locale/cmucl.pot
=====================================
@@ -8750,11 +8750,11 @@ msgid "Internal error in floating point reader."
msgstr ""
#: src/code/reader.lisp
-msgid "Number not representable as a ~S: ~S"
+msgid "Floating point underflow when reading ~S: ~S"
msgstr ""
#: src/code/reader.lisp
-msgid "Floating point underflow when reading ~S: ~S"
+msgid "Number not representable as a ~S: ~S"
msgstr ""
#: src/code/reader.lisp
=====================================
tests/float.lisp
=====================================
@@ -247,3 +247,44 @@
(assert-equal 0.9999999999999999d0
(rounding-test 3d0))))
+(define-test reader.underflow-enabled
+ (:tag :issues)
+ ;; Test with FP underflow enabled, we can still read denormals
+ ;; without problem. For this test we only care that we get a
+ ;; number, not the actual value.
+ (dolist (n (list least-positive-single-float
+ least-positive-normalized-single-float
+ (/ (+ least-positive-single-float
+ least-positive-normalized-single-float)
+ 2)
+ least-positive-double-float
+ least-positive-normalized-double-float
+ (/ (+ least-positive-double-float
+ least-positive-normalized-double-float)
+ 2)
+ ))
+ (assert-true (floatp
+ (ext:with-float-traps-enabled (:underflow)
+ (read-from-string (format nil "~A" n)))))))
+
+(define-test reader-restarts.underflow
+ (:tag :issues)
+ ;; Test that we get a restart when reading floating-point numbers
+ ;; that are too small to fit in a float. Invoke the restart to
+ ;; return 0. All the numbers must be less than half the
+ ;; leasst-positive float.
+ (dolist (item '(("1e-46" 0f0)
+ ("1e-999" 0f0)
+ ("1d-324" 0d0)
+ ("1d-999" 0d0)))
+ (destructuring-bind (string expected-value)
+ item
+ (assert-equal expected-value
+ (values (handler-bind
+ ((reader-error
+ (lambda (c)
+ (declare (ignore c))
+ (invoke-restart 'lisp::continue))))
+ (read-from-string string)))))))
+
+
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/9a811166998f97f907d0f8…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/9a811166998f97f907d0f8…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
0cbb2264 by Raymond Toy at 2024-04-10T03:10:16+00:00
Fix #296: Fix disassembly of MOVD instruction
- - - - -
df78595e by Raymond Toy at 2024-04-10T03:10:20+00:00
Merge branch 'issue-296-fix-movd-disassembly' into 'master'
Fix #296: Fix disassembly of MOVD instruction
Closes #296 and #300
See merge request cmucl/cmucl!207
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -509,6 +509,14 @@
(print-byte-reg value stream dstate)
(print-mem-access value stream t dstate)))
+(defun print-word-reg/mem (value stream dstate)
+ (declare (type (or list reg) value)
+ (type stream stream)
+ (type disassem:disassem-state dstate))
+ (if (typep value 'reg)
+ (print-word-reg value stream dstate)
+ (print-mem-access value stream nil dstate)))
+
(defun print-label (value stream dstate)
(declare (ignore dstate))
(princ (if (and (numberp value) (minusp value))
@@ -716,7 +724,11 @@
(disassem:define-argument-type byte-reg/mem
:prefilter #'prefilter-reg/mem
:printer #'print-byte-reg/mem)
-
+(disassem:define-argument-type word-reg/mem
+ ;; Like reg/mem but if the reg/mem field is a register, it's a word
+ ;; register.
+ :prefilter #'prefilter-reg/mem
+ :printer #'print-word-reg/mem)
;;;
;;; added by jrd
;;;
@@ -3478,7 +3490,7 @@
;;; We do not support the MMX version of this instruction.
(define-instruction movd (segment dst src)
(:printer ext-xmm-reg/mem ((prefix #x66) (op #x6e)))
- (:printer ext-xmm-reg/mem ((prefix #x66) (op #x7e))
+ (:printer ext-xmm-reg/mem ((prefix #x66) (op #x7e) (reg/mem nil :type 'word-reg/mem))
'(:name :tab reg/mem ", " reg))
(:emitter
(cond ((xmm-register-p dst)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/d9983ea57162a21367d9ff…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/d9983ea57162a21367d9ff…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
d9983ea5 by Raymond Toy at 2024-04-09T11:59:46-07:00
Add comment about using -V and use a better version
Explain why we use `-V` for `bin/make-dist.sh`. And instead of using
"ci-build" as the version, use `git describe --dirty` as the version.
This lets us know better what version was actually used for the build.
- - - - -
1 changed file:
- .gitlab-ci.yml
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -48,7 +48,9 @@ linux:build:
# Regular build using the cross-compiled result or snapshot
- bin/build.sh $bootstrap -R -C "x86_linux_clang" -o snapshot/bin/lisp
# - bin/build.sh $bootstrap -R -C "x86_linux" -o snapshot/bin/lisp
- - bin/make-dist.sh -V ci-build -I dist linux-4
+ # Use -V to specify the version in case some tag makes git
+ # describe return something that make-dist.sh doesn't like.
+ - bin/make-dist.sh -V `git describe --dirty` -I dist linux-4
linux:test:
stage: test
@@ -131,7 +133,9 @@ osx:build:
# Regular build using the cross-compiled result or snapshot.
# Need /opt/local/bin to get msgmerge and msgfmt programs.
- PATH=/opt/local/bin:$PATH bin/build.sh $bootstrap -R -C "" -o snapshot/bin/lisp
- - bin/make-dist.sh -V ci-build -I dist darwin-4
+ # Use -V to specify the version in case some tag makes git
+ # describe return something that make-dist.sh doesn't like.
+ - bin/make-dist.sh -V `git describe --dirty` -I dist darwin-4
osx:test:
stage: test
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/d9983ea57162a21367d9ffa…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/d9983ea57162a21367d9ffa…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-299-enable-xoroshiro-assem-routine at cmucl / cmucl
Commits:
ed577605 by Raymond Toy at 2024-04-08T20:22:10-07:00
Specify version when running make-dist.sh
Also print out the GIT_HASH so we can see why the -V option seems to
be needed now.
- - - - -
2 changed files:
- .gitlab-ci.yml
- bin/make-dist.sh
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -48,7 +48,7 @@ linux:build:
# Regular build using the cross-compiled result or snapshot
- bin/build.sh $bootstrap -R -C "x86_linux_clang" -o snapshot/bin/lisp
# - bin/build.sh $bootstrap -R -C "x86_linux" -o snapshot/bin/lisp
- - bin/make-dist.sh -I dist linux-4
+ - bin/make-dist.sh -V ci-build -I dist linux-4
linux:test:
stage: test
@@ -131,7 +131,7 @@ osx:build:
# Regular build using the cross-compiled result or snapshot.
# Need /opt/local/bin to get msgmerge and msgfmt programs.
- PATH=/opt/local/bin:$PATH bin/build.sh $bootstrap -R -C "" -o snapshot/bin/lisp
- - bin/make-dist.sh -I dist darwin-4
+ - bin/make-dist.sh -V ci-build -I dist darwin-4
osx:test:
stage: test
=====================================
bin/make-dist.sh
=====================================
@@ -98,6 +98,8 @@ def_arch_os
# ("snapshot-yyyy-mm") or a release number..
GIT_HASH="`(cd src; git describe --dirty 2>/dev/null)`"
+echo GIT_HASH = ${GIT_HASH}
+
if expr "X${GIT_HASH}" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]' > /dev/null; then
DEFAULT_VERSION=`expr "${GIT_HASH}" : "snapshot-\(.*\)"`
fi
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/ed5776053ba1c8db18bf20a…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/ed5776053ba1c8db18bf20a…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-299-enable-xoroshiro-assem-routine at cmucl / cmucl
Commits:
7543b720 by Raymond Toy at 2024-04-02T08:10:23-07:00
Fix #298: Add with-float-rounding-mode macro
Add `ext:with-float-rounding-mode` macro to set the FP rounding mode
to be used when executing the body.
- - - - -
bf417b47 by Raymond Toy at 2024-04-02T08:33:30-07:00
Update cmucl.pot with new docstrings
- - - - -
e32034e0 by Raymond Toy at 2024-04-02T08:33:52-07:00
Add tests for with-float-rounding-mode
Not 100% sure the expected results are right. They seem plausible,
but I didn't actually analyze that the rounding is correct.
- - - - -
3cdf6b8f by Raymond Toy at 2024-04-06T08:33:14-07:00
Reorder bug list to be numerically ascending.
No other changes.
- - - - -
62631e15 by Raymond Toy at 2024-04-07T22:52:52+00:00
Fix #297: Print new-assem:assemble with less indentation
- - - - -
7bec290f by Raymond Toy at 2024-04-07T22:53:01+00:00
Merge branch 'issue-297-pprint-assemble' into 'master'
Fix #297: Print new-assem:assemble with less indentation
Closes #297
See merge request cmucl/cmucl!203
- - - - -
bb1bc462 by Raymond Toy at 2024-04-07T22:53:45+00:00
Fix #300: Reduce code duplication in random
- - - - -
94a2c674 by Raymond Toy at 2024-04-07T22:53:51+00:00
Merge branch 'issue-300-reduce-code-dup-in-random' into 'master'
Fix #300: Reduce code duplication in random
Closes #300
See merge request cmucl/cmucl!206
- - - - -
6ba75434 by Carl Shapiro at 2024-04-07T23:19:27+00:00
Make variable names consistent.
- - - - -
b8923ba5 by Raymond Toy at 2024-04-08T00:00:36+00:00
Fix #295: Add docstring for define-assembly-routine
- - - - -
e77ded50 by Raymond Toy at 2024-04-08T00:00:39+00:00
Merge branch 'issue-295-docstring-for-define-assembly-routine' into 'master'
Fix #295: Add docstring for define-assembly-routine
Closes #295
See merge request cmucl/cmucl!204
- - - - -
0e716eab by Raymond Toy at 2024-04-07T17:02:55-07:00
Fix typos caused by renaming
We renamed `old-rounding-mode` to `old-mode`, but forgot to update all
uses.
- - - - -
6181fd24 by Raymond Toy at 2024-04-08T05:52:20-07:00
Fix up docstring for with-float-rounding-mode
Mention that the allowed values are the same as the values for the
rounding-mode in `set-floating-point-modes`.
Change indentation of docstring slightly so that it prints nicely via
`describe`. (Emacs doesn't indent the docstring by the right amount
for `describe`.)
- - - - -
659c41bc by Raymond Toy at 2024-04-08T05:58:05-07:00
Remove extra trailing space after period.
- - - - -
1cb2cb14 by Raymond Toy at 2024-04-08T13:00:08+00:00
Fix #294: Implement assembly routine for xoroshiro update
- - - - -
574eef63 by Raymond Toy at 2024-04-08T13:00:12+00:00
Merge branch 'issue-294-xoroshiro-lisp-assem-routine' into 'master'
Fix #294: Implement assembly routine for xoroshiro update
Closes #294
See merge request cmucl/cmucl!202
- - - - -
07a1669b by Raymond Toy at 2024-04-08T06:05:43-07:00
Update cmucl.pot for changed docstring for with-float-rounding-mode.
- - - - -
a46a530e by Raymond Toy at 2024-04-08T14:00:18+00:00
Merge branch 'issue-298-with-float-rounding-mode' into 'master'
Fix #298: Add with-float-rounding-mode macro
Closes #298
See merge request cmucl/cmucl!205
- - - - -
e03317ce by Raymond Toy at 2024-04-08T10:34:12-07:00
Merge branch 'master' into issue-299-enable-xoroshiro-assem-routine
- - - - -
4 changed files:
- src/code/exports.lisp
- src/code/float-trap.lisp
- src/i18n/locale/cmucl.pot
- tests/float.lisp
Changes:
=====================================
src/code/exports.lisp
=====================================
@@ -1591,7 +1591,8 @@
"FLOAT-NAN-P" "FLOAT-TRAPPING-NAN-P"
"FLOAT-SIGNALING-NAN-P"
"WITH-FLOAT-TRAPS-MASKED"
- "WITH-FLOAT-TRAPS-ENABLED")
+ "WITH-FLOAT-TRAPS-ENABLED"
+ "WITH-FLOAT-ROUNDING-MODE")
;; More float extensions
#+double-double
(:export "LEAST-POSITIVE-NORMALIZED-DOUBLE-DOUBLE-FLOAT"
=====================================
src/code/float-trap.lisp
=====================================
@@ -27,7 +27,8 @@
decode-floating-point-modes
encode-floating-point-modes
with-float-traps-masked
- with-float-traps-enabled))
+ with-float-traps-enabled
+ with-float-rounding-mode))
(in-package "VM")
(eval-when (compile load eval)
@@ -495,3 +496,34 @@
accrued exceptions are cleared at the start of the body to support
their testing within, and restored on exit."))
+(defmacro with-float-rounding-mode ((rounding-mode) &body body)
+ _N"Execute BODY with the floating-point rounding mode set to
+ ROUNDING-MODE. ROUNDING-MODE must be a one:
+
+ :NEAREST
+ the default mode of round to nearest even.
+ :ZERO
+ round numbers down towards zero. Positive numbers round down
+ and negative numbers round up.
+ :POSITIVE-INFINITY
+ round numbers up towards positive infinity.
+ :NEGATIVE-INFINITY
+ round numbers down towards negative infinity.
+
+ These are the same as the possible values for the rounding mode in
+ SET-FLOATING-POINT-MODES.
+
+ Only the rounding mode is restored on exit; other floating-point
+ modes are not modified."
+ (let ((old-mode (gensym "OLD-MODE-"))
+ (new-mode (gensym "NEW-MODE-")))
+ `(let ((,old-mode (ldb float-rounding-mode (floating-point-modes)))
+ (,new-mode (cdr (assoc ,rounding-mode rounding-mode-alist))))
+ (unwind-protect
+ (progn
+ (setf (floating-point-modes)
+ (dpb ,new-mode float-rounding-mode (floating-point-modes)))
+ ,@body)
+ ;; Restore just the rounding mode to the original value.
+ (setf (floating-point-modes)
+ (dpb ,old-mode float-rounding-mode (floating-point-modes)))))))
=====================================
src/i18n/locale/cmucl.pot
=====================================
@@ -4868,6 +4868,28 @@ msgid ""
" their testing within, and restored on exit."
msgstr ""
+#: src/code/float-trap.lisp
+msgid ""
+"Execute BODY with the floating-point rounding mode set to\n"
+" ROUNDING-MODE. ROUNDING-MODE must be a one:\n"
+"\n"
+" :NEAREST\n"
+" the default mode of round to nearest even.\n"
+" :ZERO\n"
+" round numbers down towards zero. Positive numbers round down\n"
+" and negative numbers round up.\n"
+" :POSITIVE-INFINITY\n"
+" round numbers up towards positive infinity.\n"
+" :NEGATIVE-INFINITY\n"
+" round numbers down towards negative infinity.\n"
+"\n"
+" These are the same as the possible values for the rounding mode in\n"
+" SET-FLOATING-POINT-MODES.\n"
+"\n"
+" Only the rounding mode is restored on exit; other floating-point\n"
+" modes are not modified."
+msgstr ""
+
#: src/code/float.lisp
msgid "Return true if the float X is denormalized."
msgstr ""
=====================================
tests/float.lisp
=====================================
@@ -212,3 +212,38 @@
;; most-positive-double-float. And a really big single-float.
(assert-error 'reader-error (read-from-string "1.8d308"))
(assert-error 'reader-error (read-from-string "1d999999999")))
+
+(defun rounding-test (x)
+ (declare (double-float x)
+ (optimize (speed 3)))
+ (* x (/ 1d0 x)))
+
+(define-test rounding-mode.nearest
+ (:tag :issues)
+ (ext:with-float-rounding-mode (:nearest)
+ (assert-equal 1d0 (rounding-test 3d0))))
+
+(define-test rounding-mode.zero.1
+ (:tag :issues)
+ (ext:with-float-rounding-mode (:zero)
+ (assert-equal 0.9999999999999999d0
+ (rounding-test 3d0))))
+
+(define-test rounding-mode.zero.2
+ (:tag :issues)
+ (ext:with-float-rounding-mode (:zero)
+ (assert-equal 0.9999999999999999d0
+ (rounding-test -3d0))))
+
+(define-test rounding-mode.positive-infinity
+ (:tag :issues)
+ (ext:with-float-rounding-mode (:positive-infinity)
+ (assert-equal 1.0000000000000002d0
+ (rounding-test 3d0))))
+
+(define-test rounding-mode.negative-infinity
+ (:tag :issues)
+ (ext:with-float-rounding-mode (:negative-infinity)
+ (assert-equal 0.9999999999999999d0
+ (rounding-test 3d0))))
+
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/883a999e350cd4a0d86bdd…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/883a999e350cd4a0d86bdd…
You're receiving this email because of your account on gitlab.common-lisp.net.