Browse code
Add some code for IEEE float compatibility
Fernando Borretti authored on 31/01/2015 00:31:50
Showing 1 changed files
Showing 1 changed files
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,25 @@ |
1 |
+(in-package :cl-user) |
|
2 |
+(defpackage yaml.float |
|
3 |
+ (:use :cl) |
|
4 |
+ (:export :*float-strategy*) |
|
5 |
+ (:documentation "Handle IEEE floating point values.")) |
|
6 |
+(in-package :yaml.float) |
|
7 |
+ |
|
8 |
+(defparameter *float-strategy* :keyword) |
|
9 |
+ |
|
10 |
+#+sbcl |
|
11 |
+(defparameter *sbcl-nan-value* |
|
12 |
+ (sb-int:with-float-traps-masked (:overflow :invalid :divide-by-zero) |
|
13 |
+ (- sb-ext:double-float-positive-infinity |
|
14 |
+ sb-ext:double-float-positive-infinity))) |
|
15 |
+ |
|
16 |
+(defun nan-value () |
|
17 |
+ (case *float-strategy* |
|
18 |
+ (:error |
|
19 |
+ (error 'yaml.error:unsupported-float-value)) |
|
20 |
+ (:keyword |
|
21 |
+ :NaN) |
|
22 |
+ (:best-effort |
|
23 |
+ #+allegro #.excl:*nan-double* |
|
24 |
+ #+sbcl *sbcl-nan-value* |
|
25 |
+ #-(or allegro sbcl) :NaN))) |