Raymond Toy pushed to branch issue-474-print-parse-hex-floats at cmucl / cmucl
Commits:
-
538acc32
by Raymond Toy at 2026-02-23T19:18:53-05:00
-
fd6d177f
by Raymond Toy at 2026-02-23T19:19:14-05:00
-
02e0f002
by Raymond Toy at 2026-02-23T18:27:46-08:00
4 changed files:
Changes:
| ... | ... | @@ -724,7 +724,3 @@ |
| 724 | 724 | ;; contents. Is there a better way?
|
| 725 | 725 | (when ,dirname
|
| 726 | 726 | (delete-directory ,dirname :recursive t)))))) |
| 727 | - |
|
| 728 | - |
|
| 729 | - |
|
| 730 | - |
| ... | ... | @@ -57,6 +57,7 @@ public domain. |
| 57 | 57 | * #460: Unit tests were not being recognized as failing on CI.
|
| 58 | 58 | * #463: `double-double-float` is missing comparison operations
|
| 59 | 59 | between `double-double-float` and `double-float`
|
| 60 | + * #474: Add functions to print and parse C-style hex floats.
|
|
| 60 | 61 | * Other changes:
|
| 61 | 62 | * Improvements to the PCL implementation of CLOS:
|
| 62 | 63 | * Changes to building procedure:
|
| ... | ... | @@ -6060,6 +6060,38 @@ msgid "" |
| 6060 | 6060 | " afterward."
|
| 6061 | 6061 | msgstr ""
|
| 6062 | 6062 | |
| 6063 | +#: src/code/ext-code.lisp
|
|
| 6064 | +msgid ""
|
|
| 6065 | +"Prints a single or double float in bit-perfect C-style hex.\n"
|
|
| 6066 | +" If AT-P is true, prepends '+' for non-negative finite values."
|
|
| 6067 | +msgstr ""
|
|
| 6068 | + |
|
| 6069 | +#: src/code/ext-code.lisp
|
|
| 6070 | +msgid ""
|
|
| 6071 | +"Convert FLOAT to C-style hex string and write it to STREAM.\n"
|
|
| 6072 | +" Infinities are printed as \"-inf\" and \"inf\". NaN is printed as\n"
|
|
| 6073 | +" \"nan\"."
|
|
| 6074 | +msgstr ""
|
|
| 6075 | + |
|
| 6076 | +#: src/code/ext-code.lisp
|
|
| 6077 | +msgid ""
|
|
| 6078 | +"Formatter for ~/ext:format-hex-float/. \n"
|
|
| 6079 | +" Uses AT-SIGN-P (@) to force the sign. COLON-P (:) is currently ignored."
|
|
| 6080 | +msgstr ""
|
|
| 6081 | + |
|
| 6082 | +#: src/code/ext-code.lisp
|
|
| 6083 | +msgid ""
|
|
| 6084 | +"Reads a C-style hex float number from STREAM. A single-float or\n"
|
|
| 6085 | +" double-float number is returned. A HEX-PARSE-ERROR is signaled for\n"
|
|
| 6086 | +" an invalid format."
|
|
| 6087 | +msgstr ""
|
|
| 6088 | + |
|
| 6089 | +#: src/code/ext-code.lisp
|
|
| 6090 | +msgid ""
|
|
| 6091 | +"Parse a C-style hex float number from OBJ which is either a string or a "
|
|
| 6092 | +"stream."
|
|
| 6093 | +msgstr ""
|
|
| 6094 | + |
|
| 6063 | 6095 | #: src/code/commandline.lisp
|
| 6064 | 6096 | msgid "A list of all the command line arguments after --"
|
| 6065 | 6097 | msgstr ""
|
| ... | ... | @@ -579,27 +579,6 @@ |
| 579 | 579 | (assert-equal -2w300
|
| 580 | 580 | (* -2w300 1w0)))
|
| 581 | 581 | |
| 582 | - |
|
| 583 | - |
|
| 584 | -;; Rudimentary code to read C %a formatted numbers that look like
|
|
| 585 | -;; "-0x1.c4dba4ba1ee79p-620". We assume STRING is exactly in this
|
|
| 586 | -;; format. No error-checking is done.
|
|
| 587 | -#+nil
|
|
| 588 | -(defun ext:parse-hex-float (string)
|
|
| 589 | - (let* ((sign (if (char= (aref string 0) #\-)
|
|
| 590 | - -1
|
|
| 591 | - 1))
|
|
| 592 | - (dot-posn (position #\. string))
|
|
| 593 | - (p-posn (position #\p string))
|
|
| 594 | - (lead (parse-integer string :start (1- dot-posn) :end dot-posn))
|
|
| 595 | - (frac (parse-integer string :start (1+ dot-posn) :end p-posn :radix 16))
|
|
| 596 | - (exp (parse-integer string :start (1+ p-posn))))
|
|
| 597 | - (* sign
|
|
| 598 | - (scale-float (float (+ (ash lead 52)
|
|
| 599 | - frac)
|
|
| 600 | - 1d0)
|
|
| 601 | - (- exp 52)))))
|
|
| 602 | - |
|
| 603 | 582 | ;; Relative error in terms of bits of accuracy. This is the
|
| 604 | 583 | ;; definition used by Baudin and Smith. A result of 53 means the two
|
| 605 | 584 | ;; numbers have identical bits. For complex numbers, we use the min
|