forked from alex-eg/sex
read hex floats
0x1.8p3 was no number to the reader, so it became a symbol C got inside |pipes|, and _ could not type it. It reads now as a literal written as it was: the digits of a double's own bits, which no decimal rounds to.
This commit is contained in:
@@ -1220,12 +1220,14 @@
|
||||
;;; 1 -> int 1u -> (unsigned int)
|
||||
;;; 4000000000 -> (long long) 10L -> long
|
||||
;;; 1.5f -> float 0.1L -> (long double)
|
||||
;;; 0x1.8p3 -> double
|
||||
(define (c-literal-type literal)
|
||||
(let ((n (c-literal-value literal))
|
||||
(suffix (map char-downcase (string->list (c-literal-suffix literal)))))
|
||||
(cond ((exact? n) (integer-literal-type n suffix))
|
||||
((memv #\f suffix) 'float)
|
||||
(else '(long double)))))
|
||||
((memv #\l suffix) '(long double))
|
||||
(else 'double))))
|
||||
|
||||
(define (integer-literal-type n suffix)
|
||||
(let ((ranks (drop (if (memv #\u suffix)
|
||||
|
||||
Reference in New Issue
Block a user