• (nodebb)

    Fortunately, they were experienced enough to declare it as an unsigned long to avoid . . . never mind.

    Addendum 2025-05-20 06:40: ah, Java doesn't actually have that, mea culpa.

  • Smithers (unregistered)

    While 0xFFFFFFFF is a valid literal in Java, it would also be the wrong literal. As dpm noted, Java does not have unsigned types like C(++) does, but it does guarantee that long is exactly 64 bits and int 32. 0xFFFFFFFF would be a literal of type int and therefore have the value -1. Maybe the author found that out the hard way and that's how this code was born.

    What they really wanted, of course, is private static final long BITMASK32 = 0xFFFFFFFFL;

  • (nodebb)

    TRWTF is Java (ducks)

  • (nodebb)

    FFFFFFFFF is the sound that one makes when seeing code like this

  • (nodebb) in reply to adamantoise

    No, the sound you're thinking of is "AAAAAAAAAAAAAAAAH! Run away! Run away!"

  • (nodebb)

    There used to be a restaurant in Janesville, WI named HHFFRRRGH (pronounced huff-FARG). I submit that would be just as good (if not better) of variable name.

  • (nodebb)

    I'm learning the difference between "TWENTY = 20" and "FFFFFFFF = 0xFFFFFFFF". While 20 is pretty easy to verify in one's code, it's easy to be off-by-one in a string of Fs. By using a symbol instead of a literal, one benefits from syntax checking in the IDE and the compiler.

  • (nodebb)

    TRWTF is that the constant is not declared final.

  • Ex-Java dev (unregistered)

    While I enjoy twiddling bits as much as most devs, the proper way to do this in Java is the BitSet class.

    I actually used that, and wrote it out to a MSSql table as.. a bigint, I think? at my old job. Then I did the unthinkable and made a view into said table that converted the compressed bit data and separated it out into individual enum values stored in another table. Lots of pow() functions, if memory serves.

    I don't think anyone was dumb enough to use that human-query-only view for automated processes (rather than the service API, which is how it was supposed to be done), but who knows!

  • OldCoder (unregistered) in reply to sibtrag

    So why not name it ALL_BITS?

  • (nodebb)

    If you actually have to deal with hex numbers, isn't Java a bad choice in general. It doesn't even have unsigned types.

  • (nodebb) in reply to OldCoder

    Absolutely, I do prefer more descriptive values. If Smithers is correct that "long" values are 64-bits, then maybe "SOME_BITS" or "LOW_WORD" would be appropriate.

  • Alan Scrivener (unregistered)
    Comment held for moderation.

Leave a comment on “What the FFFFFFFF”

Log In or post as a guest

Replying to comment #:

« Return to Article