View Poll Results: Preference - Letters in Hexadecimal Values Upper- or Lower-Case?

Voters
21. You may not vote on this poll
  • I prefer upper-case

    11 52.38%
  • I prefer lower-case

    3 14.29%
  • I don't have a preference either way

    6 28.57%
  • Stop wasting our time with senseless polls

    1 4.76%
Like Tree26Likes

Preference - Letters in Hexadecimal Values Upper- or Lower-Case?

This is a discussion on Preference - Letters in Hexadecimal Values Upper- or Lower-Case? within the General Discussions forums, part of the Community Boards category; A trivial question, but something I've been curious about for a while. I prefer to see them as upper case, ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2,292

    Preference - Letters in Hexadecimal Values Upper- or Lower-Case?

    A trivial question, but something I've been curious about for a while.

    I prefer to see them as upper case, purely for aesthetic reasons. Since numbers are typically of equal height, I like the letters in hex values to also be the same height.

    Code:
    0A B2 3C FE    // nice and uniform
    
    0a b2 3c fe    // sloppy-looking (in my opinion)
    However, I've seen many instances of lower-case, both in source code and as program output.

    Which is your preference, and why?




    Bonus question: What about the 'x' that denotes hexadecimal? I like that to be lower-case, as it is an indication of base and does not contribute to the value:

    Code:
    0xFF    // I prefer to see this...
    
    0XFF    // ...instead of this

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,610
    You forgot about the hexadecimal-post notation, like 'FFh', which is especially commonplace in assembly.

    I prefer uppercase digits with a lowercase 'x', for aesthetics, same as you. But I've become more tolerant to other styles with time, since I often don't have a choice as to how I get to see them.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    I answered that I don't have a preference either way. I do think it should be "0x" and not "0X", though.
    Mario F. and Elkvis like this.
    Sent from my iPad®

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Quote Originally Posted by SlyMaelstrom View Post
    I do think it should be "0x" and not "0X", though.
    Yeah. For some reason 0X irks me like few things do.

    But seriously, the decision to use lowercase or uppercase should be based on exactly what you want to do. It's not a matter of personal preference like some here will tell you:

    You should write 0xDEAF and not 0xdeaf, or you risk not being heard.
    Write 0xffffff is you want to use the color white instead of the color WHITE.
    Respect acronyms. It's 0xCAD, not 0xcad.
    Avoid writing either 0xBED or 0xbed on your first date.
    cyberfish and Epy like this.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,669
    I type lower case hex numbers without thinking most of the time, but it doesn't matter to me.

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,231
    O_o

    My only preference: DO NOT USE MIXED-CASE!

    Seriously, for the love/hate of any handy gods, do not use mixed-case values.

    Soma
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  7. #7
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    1,052
    Mario, I care to disagree. Lower case is obviously superior and is much more similar to how we read normally. UNLESS YOU WANT ME TO TYPE LIKE THIS BECAUSE YOU'RE SCARED OF NOT BEIN' HURD. XD

    As a sidenote, XD should never be xd as that's not even someone sticking their tongue out anymore.

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    2,292
    Interesting results. So far, it seems that a majority of those who voted do have a preference one way or another. And one person took the bait and voted for the humorous item.

    @Yarin - Good point. I was so engrossed in my preferred method of "0x" while working on a project that I didn't even consider the post notation when writing up the "bonus question".

    I'm writing code for a Silicon Labs device, so the 'h' suffix is supported by the environment, but I'm still choosing to use the "0x" prefix anyway. (If I did use the 'h' instead, I would prefer lower-case, for the same reasons I prefer the lower-case 'x'.)

    @MutantJohn - I would agree but for the fact that hex values are not words; I see them as numbers in that context, and as such prefer upper-case for the reason I mentioned above. But that's just my own personal opinion on the matter.

    @phantomotap - Based on your reaction, it sounds like you might have actually come across mixed-case in the wild. Is that so? I'd be appalled by that, as well!

    Upon further research, the C99 draft standard explicitly supports upper- and lower-case hex values, as well as the 'x' (6.4.4.1). No surprise there really, but still good to know.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Quote Originally Posted by Matticus View Post
    I would agree but for the fact that hex values are not words
    Well sir, I'll say this: in your 0xFACE, mister!
    Matticus likes this.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Registered User
    Join Date
    Jun 2011
    Posts
    2,292
    Byte me
    Mario F., Yarin and Elysia like this.

  11. #11
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    0xDEADBEEF is tasty.

    I voted uppercase with lower x... obviously.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  12. #12
    Registered User
    Join Date
    Jun 2011
    Posts
    2,292
    How about a hex haiku (hex-ku?) about an insect who gets hit by one of those advertising fins mounted on top of a taxi during a rain storm?

    Code:
    DEAF BEE FACED A CAB
    
    FADED, EBBED, FACED A BED, DEAD
    
    DABBED A BEADED AD
    Wow, that's pretty terrible.
    anduril462 likes this.

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    0x rather than 0X. 0X is just ugly.

    Other than that upper case instead of lower. I don't know why it's just my preference.

    So 0x combined with uppercase for me.

  14. #14
    Registered User
    Join Date
    Jun 2005
    Posts
    6,264
    Quote Originally Posted by VirtualAce View Post
    0x rather than 0X. 0X is just ugly.

    Other than that upper case instead of lower.
    I'm with VirtualAce on that one, except that the reason is that it stands out when needed.

    1) With lowercase digits (a,b,c) there is potential to misread - being human - a hex value as a variable (or worse, a function) name. My coding style avoids pure uppercase for variable or function names. (I also avoid using macros where possible in C code, so that doesn't run afoul of guidelines to write macro names in uppercase).

    2) The 'x' in "0x" stands out better from hex digits in lower case than upper (a visual difference of height for 0xABC as opposed to 0XABC) - a distinct visual cue it is a hex value even if all digits are in the range [0,9]. That is also useful for recognising the difference from octal values (all I need to do is look for a leading '0' and, if it is followed immediately by a less-tall character, it is hex rather than octal).

    Given that none of the available poll options capture my preference, I haven't voted.
    Right 98% of the time, and don't care about the other 3%.

  15. #15
    Registered User
    Join Date
    Jun 2005
    Posts
    6,264
    Quote Originally Posted by VirtualAce View Post
    0x rather than 0X. 0X is just ugly.

    Other than that upper case instead of lower.
    I'm with VirtualAce on that one, except that the reason is that it stands out when needed.

    1) With lowercase digits (a,b,c) there is potential to misread - being human - a hex value as a variable (or worse, a function) name. My coding style avoids pure uppercase for variable or function names. (I also avoid using macros where possible in C code, so that doesn't run afoul of guidelines to write macro names in uppercase).

    2) The 'x' in "0x" stands out better from hex digits in lower case than upper (a visual difference of height for 0xABC as opposed to 0XABC) - a distinct visual cue it is a hex value even if all digits are in the range [0,9]. That is also useful for recognising the difference from octal values (all I need to do is look for a leading '0' and, if it is followed immediately by a less-tall character, it is hex rather than octal).

    Given that none of the available poll options capture my preference, I haven't voted.
    Right 98% of the time, and don't care about the other 3%.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String upper-lower case
    By icor15 in forum C Programming
    Replies: 1
    Last Post: 11-26-2012, 02:00 AM
  2. Replies: 11
    Last Post: 04-11-2011, 05:52 PM
  3. Replies: 6
    Last Post: 03-07-2011, 01:15 PM
  4. help...Lower and Upper case problem only
    By j4k50n in forum C Programming
    Replies: 9
    Last Post: 04-19-2007, 12:39 AM
  5. upper case to lower case problem
    By Jasonymk in forum C++ Programming
    Replies: 3
    Last Post: 04-27-2003, 05:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21