Skip to content

Commit

Permalink
various: add infinityp trait
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Aug 21, 2024
1 parent 296d148 commit 7c90515
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 142 deletions.
39 changes: 23 additions & 16 deletions code/condition/utility.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
: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))))
(quaviver:triple-float nil float-type
(quaviver:primitive-base float-type)
0 0 sign))))

(defun floating-point-overflow (float-type sign operation &rest operands)
(restart-case
Expand All @@ -19,18 +21,23 @@
(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))))
"Recover using~:[ the most~;~] ~:[negative~;positive~] ~:[floating point~;infinity~] as the value."
(quaviver:infinityp float-type)
(plusp sign)
(quaviver:infinityp float-type)))
(cond ((quaviver:infinityp float-type)
(quaviver:triple-float nil float-type
(quaviver:primitive-base float-type)
0 :infinity sign))
((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)))
(t
(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)))))))
4 changes: 3 additions & 1 deletion code/interface.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@

(defgeneric non-number-p (type))

(defgeneric internal-base (type))
(defgeneric infinityp (type))

(defgeneric primitive-base (type))

(defgeneric exponent-bias (type)
(:method (type)
Expand Down
3 changes: 2 additions & 1 deletion code/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#:hidden-bit-p
#:subnormalp
#:non-number-p
#:internal-base
#:infinityp
#:primitive-base
#:exponent-bias
#:max-exponent
#:min-exponent
Expand Down
124 changes: 0 additions & 124 deletions code/traits.lisp

This file was deleted.

0 comments on commit 7c90515

Please sign in to comment.