Welcome to the CHICKEN Scheme pasting service

flonum-edge-value-encoding added by evhan on Thu Jun 27 10:45:48 2019

commit 8e226395197515fe5aac0ac6e0bf3a17a7584394
Author: Evan Hanson <evhan@foldling.org>
Date:   Thu Jun 27 16:34:36 2019 +1200

    Emit C99 constants for +nan.0 and [+-]inf.0 `##core#float' nodes
    
    The unboxing pass added in 79cf7427 introduces a `##core#float' type to
    the closure-converted language, for which floating point literals are
    emitted inline. This also needs to handle NaN and infinite values. For
    these, we use the NAN and INFINITY constants defined by C99.
    
    Fixes #1626.

diff --git a/c-backend.scm b/c-backend.scm
index 2ef2337f..a7783379 100644
--- a/c-backend.scm
+++ b/c-backend.scm
@@ -127,7 +127,12 @@
 		   (gen "lf[" (first params) #\])) ) )
 
             ((##core#float)
-             (gen (first params)))
+	     (let ((n (first params)))
+	       (cond ((nan? n) (gen "NAN"))
+		     ((infinite? n)
+		      (when (negative? n) (gen #\-))
+		      (gen "INFINITY"))
+		     (else (gen n)))))
 
 	    ((if)
 	     (gen #t "if(C_truep(")

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg implements the CHICKEN wiki?
Visually impaired? Let me spell it for you (wav file) download WAV