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:
2026-10-16 14:44:29 +03:00
parent c72b19035d
commit 3abb39854b
5 changed files with 55 additions and 16 deletions

View File

@@ -1225,12 +1225,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)