-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
various: add recoverable overflow and underflow
- Loading branch information
Showing
5 changed files
with
57 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
(in-package #:quaviver.condition) | ||
|
||
(defun floating-point-overflow (operation &rest operands) | ||
(error 'cl:floating-point-overflow | ||
:operation operation | ||
:operands operands)) | ||
(defun floating-point-underflow (float-type sign operation &rest operands) | ||
(restart-case | ||
(error 'cl:floating-point-underflow | ||
:operation operation | ||
:operands operands) | ||
(recover () | ||
:report (lambda (stream) | ||
(format stream "Recover using ~:[negative~;positive~] zero as the value." | ||
(plusp sign))) | ||
(quaviver:triple-float nil float-type 2 0 0 sign)))) | ||
|
||
(defun floating-point-underflow (operation &rest operands) | ||
(error 'cl:floating-point-underflow | ||
:operation operation | ||
:operands operands)) | ||
(defun floating-point-overflow (float-type sign operation &rest operands) | ||
(restart-case | ||
(error 'cl:floating-point-overflow | ||
:operation operation | ||
:operands operands) | ||
(recover () | ||
:report (lambda (stream) | ||
(format stream | ||
#+clisp "Recover using the most ~:[negative~;positive~] floating point as the value." | ||
#-clisp "Recover using ~:[negative~;positive~] infinity as the value." | ||
(plusp sign))) | ||
#+clisp (if (minusp sign) | ||
(ecase float-type | ||
(short-float most-negative-short-float) | ||
(single-float most-negative-single-float) | ||
(double-float most-negative-double-float) | ||
(long-float most-negative-long-float)) | ||
(ecase float-type | ||
(short-float most-positive-short-float) | ||
(single-float most-positive-single-float) | ||
(double-float most-positive-double-float) | ||
(long-float most-positive-long-float))) | ||
#-clisp (quaviver:triple-float nil float-type 2 0 :infinity sign)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters