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%

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

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513

    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
    2,158
    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.

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

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    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.
    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
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    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
    5,108
    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
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  7. #7
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    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
    4,513
    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
    Ireland
    Posts
    8,446
    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!
    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
    4,513
    Byte me

  11. #11
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    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
    4,513
    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.

  13. #13
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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,815
    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%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  15. #15
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    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%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

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, 03:00 AM
  2. Replies: 11
    Last Post: 04-11-2011, 05:52 PM
  3. Replies: 6
    Last Post: 03-07-2011, 02: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