1 ;;; -*- show-trailing-whitespace: t; indent-tabs: nil -*-
3 ;;;; Copyright (c) 2003,2004 David Lichteblau <david@lichteblau.com>
5 ;;; Redistribution and use in source and binary forms, with or without
6 ;;; modification, are permitted provided that the following conditions
9 ;;; * Redistributions of source code must retain the above copyright
10 ;;; notice, this list of conditions and the following disclaimer.
12 ;;; * Redistributions in binary form must reproduce the above
13 ;;; copyright notice, this list of conditions and the following
14 ;;; disclaimer in the documentation and/or other materials
15 ;;; provided with the distribution.
17 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
18 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 (in-package :cxml-types
)
31 (defun do-not-constant-fold-me (x) x
)
36 ((and (numberp a
) (numberp b
))
38 ((member a
'(single-float-nan double-float-nan
))
40 ((member b
'(single-float-nan double-float-nan
))
42 ((member a
'(single-float-negative-infinity
43 double-float-negative-infinity
))
44 (not (member b
'(single-float-negative-infinity
45 double-float-negative-infinity
))))
46 ((member b
'(single-float-positive-infinity
47 double-float-positive-infinity
))
48 (not (member a
'(single-float-positive-infinity
49 double-float-positive-infinity
))))
56 ((and (numberp a
) (numberp b
))
60 ((member a
'(single-float-nan double-float-nan
))
61 (member b
'(single-float-nan double-float-nan
)))
62 ((member b
'(single-float-nan double-float-nan
))
67 (defparameter single-float-positive-infinity
68 #+sbcl sb-ext
:single-float-positive-infinity
69 #+allegro excl
::*infinity-single
*
70 #-
(or sbcl allegro
) 'single-float-positive-infinity
)
72 (defparameter single-float-negative-infinity
73 #+sbcl sb-ext
:single-float-negative-infinity
74 #+allegro excl
::*negative-infinity-single
*
75 #-
(or sbcl allegro
) 'single-float-negative-infinity
)
77 (defparameter double-float-positive-infinity
78 #+sbcl sb-ext
:double-float-positive-infinity
79 #+allegro excl
::*infinity-double
*
80 #-
(or sbcl allegro
) 'double-float-positive-infinity
)
82 (defparameter double-float-negative-infinity
83 #+sbcl sb-ext
:double-float-negative-infinity
84 #+allegro excl
::*negative-infinity-double
*
85 #-
(or sbcl allegro
) 'double-float-negative-infinity
)
87 (defparameter double-float-nan
88 #+sbcl
(let ((orig (sb-int:get-floating-point-modes
)))
91 (sb-int:set-floating-point-modes
:traps nil
)
92 (/ 0.0d0
(do-not-constant-fold-me 0.0d0
)))
93 (apply #'sb-int
:set-floating-point-modes orig
)))
94 #+allegro excl
::*nan-double
*
95 #-
(or sbcl allegro
) 'double-float-nan
)
97 (defparameter single-float-nan
98 #+sbcl
(let ((orig (sb-int:get-floating-point-modes
)))
101 (sb-int:set-floating-point-modes
:traps nil
)
102 (/ 0.0f0
(do-not-constant-fold-me 0.0f0
)))
103 (apply #'sb-int
:set-floating-point-modes orig
)))
104 #+allegro excl
::*nan-single
*
105 #-
(or sbcl allegro
) 'single-float-nan
)