s-expressionists / wscl

Sources of the "Well Specified Common Lisp" specification which is based on the final draft of the Common Lisp standard but is not a new Common Lisp standard.
https://s-expressionists.github.io/wscl/
Other
38 stars 4 forks source link

Uppercase vs lowercase for base >10 #25

Open lassik opened 1 year ago

lassik commented 1 year ago

Does the standard say anywhere if hex and other base>10 numbers should be printed using uppercase (as opposed to lowercase) letters? Uppercase seems to be the norm.

yitzchak commented 1 year ago

Yes, the description for DIGIT-CHAR says specifically "If the resulting character is to be an alphabetic[1] character, it will be an uppercase character." There maybe other places also.

lassik commented 1 year ago

Uppercase

Function DIGIT-CHAR (http://clhs.lisp.se/Body/f_digit_.htm#digit-char)

If the resulting character is to be an alphabetic[1] character, it will be an uppercase character.

No opinion

Variable *PRINT-BASE*, *PRINT-RADIX* (http://clhs.lisp.se/Body/v_pr_bas.htm#STprint-baseST)

For radices above 10, letters of the alphabet are used to represent digits above 9.

If the value of print-radix is true, the printer will print a radix specifier to indicate the radix in which it is printing a rational number. The radix specifier is always printed using lowercase letters. If print-base is 2, 8, or 16, then the radix specifier used is #b, #o, or #x, respectively.

2.3.2.1.1 Syntax of an Integer (http://clhs.lisp.se/Body/02_cbaa.htm)

13.1.4.6 Digits in a Radix (http://clhs.lisp.se/Body/13_adf.htm)

22.1.3.1.1 Printing Integers (http://clhs.lisp.se/Body/22_acaa.htm)

22.3.2.1 Tilde R: Radix (http://clhs.lisp.se/Body/22_cba.htm)

22.3.2.5 Tilde X: Hexadecimal (http://clhs.lisp.se/Body/22_cbe.htm)

current output base (http://clhs.lisp.se/Body/26_glo_c.htm#current_output_base)

digit (http://clhs.lisp.se/Body/26_glo_d.htm#digit)

radix (http://clhs.lisp.se/Body/26_glo_r.htm#radix)

informatimago commented 1 year ago

Note that if you want a specific case, you can use format ~:@( or ~(

cl-user> (format t "~:@(~X~) ~:*~(~X~)~%" #xbabe)
BABE babe
nil