Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uppercase vs lowercase for base >10 #25

Open
lassik opened this issue Jan 3, 2023 · 3 comments
Open

Uppercase vs lowercase for base >10 #25

lassik opened this issue Jan 3, 2023 · 3 comments

Comments

@lassik
Copy link

lassik commented Jan 3, 2023

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
Copy link
Member

yitzchak commented Jan 3, 2023

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
Copy link
Author

lassik commented Jan 3, 2023

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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants