write a double in the digits that read back as it
CHICKEN prints 15 significant digits unless told otherwise, too few to name every double: 0.9871465422297019 reached the C as 0.987146542229702, a different constant. Found in vs-map-viewer, where 380 literals in a port that has to match .NET bit for bit changed this way. The shortest spelling that reads back is written, up to 17 digits.
This commit is contained in:
@@ -789,7 +789,18 @@ whitespace aside, THEN?"
|
||||
(test-assert "a subscript"
|
||||
(emits? (in-fn "(var xs [int 4]) (var n size-t (sizeof [xs 0]))") "sizeof(xs[0])")))
|
||||
|
||||
;; A define's body was pasted unwalked, and unparenthesised: `cast'
|
||||
;; A double is written in as few digits as read back as the same
|
||||
;; double: CHICKEN prints 15 by default, and 0.16666666666666666 came
|
||||
;; out 0.166666666666667, another number
|
||||
(test-group "double literals"
|
||||
(test-assert "keep every digit they need"
|
||||
(emits? (in-fn "(var d double 0.16666666666666666)") "d = 0.16666666666666666;"))
|
||||
(test-assert "and gain none they do not"
|
||||
(emits? (in-fn "(var d double 0.1)") "d = 0.1;"))
|
||||
(test-assert "sixteen when that is enough"
|
||||
(emits? (in-fn "(var d double 0.9871465422297019)") "d = 0.9871465422297019;")))
|
||||
|
||||
;; A define's body was pasted unwalked, and unparenthesised: `cast'
|
||||
;; stayed a call, and (* x D) regrouped with D's own operator
|
||||
(test-group "defines"
|
||||
(test-assert "an atom is left bare"
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"toplevel: 1 2.5 hi 12"
|
||||
"closure in place: 5"
|
||||
"a type is not a call: 7"
|
||||
"radix literals: 224 5 128")
|
||||
"radix literals: 224 5 128"
|
||||
"a double reaches C whole: 1")
|
||||
(return 0)
|
||||
|
||||
;;; The walk types an expression by its head, and the heads it had a
|
||||
@@ -92,4 +93,8 @@
|
||||
;; a mask reads best in the radix it is a mask in
|
||||
(var lead int 0xE5)
|
||||
(printf "radix literals: %d %d %d\n" (& lead 0xE0) (& lead 0b111) #x80)
|
||||
|
||||
;; ...and a double in all the digits it was written with
|
||||
(var sixth double (/ 1.0 6.0))
|
||||
(printf "a double reaches C whole: %d\n" (== 0.16666666666666666 sixth))
|
||||
(return 0))
|
||||
|
||||
Reference in New Issue
Block a user