forked from alex-eg/sex
spell the least long long as C's LLONG_MIN
-9223372036854775808 reached C as written, where it negates an unsigned constant, and had no type for inference: it is read as -9223372036854775807 - 1, which is long long on both sides.
This commit is contained in:
@@ -234,7 +234,9 @@
|
||||
;;; Scheme reads numbers C has no literal for -- 1/2, #e1.5, 1e400,
|
||||
;;; +nan.0, 1+2i -- and they reached C as written. An integer too wide
|
||||
;;; for long long is unsigned to C, which says so only by a warning
|
||||
;;; unless it is written with a `u'; so it is.
|
||||
;;; unless it is written with a `u'; so it is. -9223372036854775808 is
|
||||
;;; one too: C negates the unsigned 9223372036854775808, so it is
|
||||
;;; spelled as LLONG_MIN is, -9223372036854775807 - 1.
|
||||
(define +llong-min+ (- (expt 2 63)))
|
||||
(define +llong-max+ (- (expt 2 63) 1))
|
||||
(define +ullong-max+ (- (expt 2 64) 1))
|
||||
@@ -245,6 +247,7 @@
|
||||
(error "too large for any C integer type" s))
|
||||
((> n +llong-max+) (make-number-literal n "u" #f))
|
||||
((< n +llong-min+) (list '- (make-number-literal (- n) "u" #f)))
|
||||
((= n +llong-min+) (list '- (+ n 1) 1))
|
||||
(else n)))
|
||||
((and (real? n) (inexact? n) (finite? n)) n)
|
||||
(else (error "C has no literal for this number" s))))
|
||||
|
||||
Reference in New Issue
Block a user