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 Revert changes that added extra blank lines at the end - - - - - fd6d177f by Raymond Toy at 2026-02-23T19:19:14-05:00 Full remove old version of parse-hex-float. We use ext:parse-hex-float now. - - - - - 02e0f002 by Raymond Toy at 2026-02-23T18:27:46-08:00 Update release notes and cmucl.pot [skip-ci] - - - - - 4 changed files: - src/code/extensions.lisp - src/general-info/release-22a.md - src/i18n/locale/cmucl.pot - tests/float.lisp Changes: ===================================== src/code/extensions.lisp ===================================== @@ -724,7 +724,3 @@ ;; contents. Is there a better way? (when ,dirname (delete-directory ,dirname :recursive t)))))) - - - - ===================================== src/general-info/release-22a.md ===================================== @@ -57,6 +57,7 @@ public domain. * #460: Unit tests were not being recognized as failing on CI. * #463: `double-double-float` is missing comparison operations between `double-double-float` and `double-float` + * #474: Add functions to print and parse C-style hex floats. * Other changes: * Improvements to the PCL implementation of CLOS: * Changes to building procedure: ===================================== src/i18n/locale/cmucl.pot ===================================== @@ -6060,6 +6060,38 @@ msgid "" " afterward." msgstr "" +#: src/code/ext-code.lisp +msgid "" +"Prints a single or double float in bit-perfect C-style hex.\n" +" If AT-P is true, prepends '+' for non-negative finite values." +msgstr "" + +#: src/code/ext-code.lisp +msgid "" +"Convert FLOAT to C-style hex string and write it to STREAM.\n" +" Infinities are printed as \"-inf\" and \"inf\". NaN is printed as\n" +" \"nan\"." +msgstr "" + +#: src/code/ext-code.lisp +msgid "" +"Formatter for ~/ext:format-hex-float/. \n" +" Uses AT-SIGN-P (@) to force the sign. COLON-P (:) is currently ignored." +msgstr "" + +#: src/code/ext-code.lisp +msgid "" +"Reads a C-style hex float number from STREAM. A single-float or\n" +" double-float number is returned. A HEX-PARSE-ERROR is signaled for\n" +" an invalid format." +msgstr "" + +#: src/code/ext-code.lisp +msgid "" +"Parse a C-style hex float number from OBJ which is either a string or a " +"stream." +msgstr "" + #: src/code/commandline.lisp msgid "A list of all the command line arguments after --" msgstr "" ===================================== tests/float.lisp ===================================== @@ -579,27 +579,6 @@ (assert-equal -2w300 (* -2w300 1w0))) - - -;; Rudimentary code to read C %a formatted numbers that look like -;; "-0x1.c4dba4ba1ee79p-620". We assume STRING is exactly in this -;; format. No error-checking is done. -#+nil -(defun ext:parse-hex-float (string) - (let* ((sign (if (char= (aref string 0) #\-) - -1 - 1)) - (dot-posn (position #\. string)) - (p-posn (position #\p string)) - (lead (parse-integer string :start (1- dot-posn) :end dot-posn)) - (frac (parse-integer string :start (1+ dot-posn) :end p-posn :radix 16)) - (exp (parse-integer string :start (1+ p-posn)))) - (* sign - (scale-float (float (+ (ash lead 52) - frac) - 1d0) - (- exp 52))))) - ;; Relative error in terms of bits of accuracy. This is the ;; definition used by Baudin and Smith. A result of 53 means the two ;; numbers have identical bits. For complex numbers, we use the min View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/68e2a5c280e67ce1b4457e6... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/68e2a5c280e67ce1b4457e6... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)