• MOVE ANONYMOUS TO YOUR-NAME (unregistered)

    Were it written in Cobol, 88 levels would have been much more elegant. :)

  • TheHun (unregistered) in reply to cthulhu

    Seriously... You can do the things you would use an actual bitmask for... instead of assigning conditions random ass integer values Windows API error style...

    By god, I think I'll use this method from now on then.

  • Jay (unregistered)

    There are 3 kinds of people in the world: Those who can count, and those who can't.

  • Jay (unregistered) in reply to SMB
    SMB:
    dmh2000:
    >If the code REALLY looks like that, there's another WTF hidden: It literally is 1111111 (decimal), not binary 1111111 aka 127

    and the first constant with a leading zero is octal, not decimal or binary.

    0001000 = 512 decimal

    ...which doesn't actually matter at all, because of the implementation. The only thing that matters is that the numbers are unique.

    I would guess that if he used the numbers 0, 1, 2, 3, 4, etc, this wouldn't look unlike implementations that we have seen a thousand times before (even if non-elegant)

    I didn't check over the numbers to see if any turn into the same value, but boy would that be a tough bug to figure out if they did!

  • foo (unregistered)

    And isn't 0... considered octal, while 1... is considered decimal? :)

  • Mr. Norrell (unregistered) in reply to this webcomic is a wtf
    this webcomic is a wtf:
    This is actually very nice, we can then change the value to a string, then test for the condition with a simple mid(str(integerflagholder),positiontotest,1). You can't do neat stuff like that with some crazy ass binary bit flipper.

    Sheesh. Of course you can.

    A binary AND can be used to check for a flag. 01100 AND 01000 = 01000, which is logically true. If the bit isn't set, the result is 0 which logically false.

    A binary OR can be used to add up flags: 01 OR 10 = 11.

  • The Entropy (unregistered) in reply to cthulhu

    What an idiot. the easiest way to set the values would be to say:

    matchpattern = (int)((char)(int)hasLastName + (char)(int)hasDob + (char)(int)hasFirstName + (char)(int)hasEmail + (char)(int)hasRefNo + (char)(int)hasTelNo + (char)(int)hasAddr);

  • umm yeah (unregistered) in reply to this webcomic is a wtf

    Fer chrissakes, write a HELPER FUNCTION to do that.

    Make it common and you NEVER HAVE TO WRITE IT AGAIN.

  • Lee Wilson (unregistered) in reply to this webcomic is a wtf

    Yes, and it's only about 10000x less efficient to do it that way... very nice indeed.

  • foo (unregistered) in reply to this webcomic is a wtf

    shut up

  • Robert (unregistered) in reply to this webcomic is a wtf

    Except, the first one is in octal ...

  • Discusted dude (unregistered) in reply to this webcomic is a wtf

    Of course you can do it with a binary bit flipper, integerflagholder & (1 << positiontotest)

    That was you can do it in 2 CPU cycles, rather than hundreds.

  • ksym (unregistered) in reply to cthulhu

    Well then, it also means that each "special case" is very much separated from others. Makes no sense to me. Who says that the actual business logic can't be "fall thru" (with possibly a few while/goto sequences) rather than "switch case"?

    I suppose the actual business logic for this case is the total opposite of DRY coding. It tends to get like that when there are OVER 9000(!!!!) socially excluded coders working on a single project.

    Just my gigazillion cents.

Leave a comment on “Boolean Integers”

Log In or post as a guest

Replying to comment #:

« Return to Article