• 0 Posts
  • 16 Comments
Joined 3 months ago
cake
Cake day: March 22nd, 2025

help-circle




  • The code is a set of preprocessor macros to stuff loads of booleans into one int (or similar), in this case named ‘myFlags’. The preprocessor is a simple (some argue too simple) step at the start of compilation that modifies the source code on its way to the real compiler by substituting #defines, prepending #include’d files, etc.

    If myFlags is equal to, e.g. 67, that’s 01000011, meaning that BV00, BV01, and BV07 are all TRUE and the others are FALSE.

    The first part is just for convenience and readability. BV00 represents the 0th bit, BV01 is the first etc. (1 << 3) means 00000001, bit shifted left three times so it becomes 00001000 (aka 8).

    The middle chunk defines macros to make bit operations more human-readable.

    SET_BIT(myFlags, MY_FIRST_BOOLEAN) gets turned into ((myFlags) |= ((1 << 0))) , which could be simplified as myFlags = myFlags | 00000001 . (Ignore the flood of parentheses, they’re there for safety due to the loaded shotgun nature of the preprocessor.)


  • Back in the day when it mattered, we did it like

    #define BV00		(1 <<  0)
    #define BV01		(1 <<  1)
    #define BV02		(1 <<  2)
    #define BV03		(1 <<  3)
    ...etc
    
    #define IS_SET(flag, bit)	((flag) & (bit))
    #define SET_BIT(var, bit)	((var) |= (bit))
    #define REMOVE_BIT(var, bit)	((var) &= ~(bit))
    #define TOGGLE_BIT(var, bit)	((var) ^= (bit))
    
    ....then...
    #define MY_FIRST_BOOLEAN BV00
    SET_BIT(myFlags, MY_FIRST_BOOLEAN)
    
    

  • I was sort of on Mike Goldman (the challenge giver)'s side until I saw the great point made at the end that the entire challenge was akin to a bar room bet; Goldman had always set it up as a kind of scam from the start and was clearly more than happy to take $100 from anyone who fell for it, and so should have taken responsibility when someone managed to meet the wording of his challenge.





  • The frustrating thing working in a big company is wanting to pay for something that costs 0.0000001% of the company’s annual revenue, but not being able to because big companies are always divided up in hundreds of small teams with their own budgets, and your boss is already over-budget for the quarter because the team’s cloud bill was 20% higher than predicted.

    This is, of course, working exactly as designed.


  • Good for you. What people from the “a vote for third party is a vote for Trump” camp don’t understand is that the two-party system is exactly how fascism was able to become standard Republican Party policy in the first place.

    A decent multi-party democracy would have enabled traditional non-fascist conservatives to break off into their own party whilst still holding seats in Congress, but instead we’ve got a whole party full of people who denounced Trump as a fascist way back in 2014 but have now kissed the ring. Likewise parties like the Greens would be able to enjoy votes from the millions of people who agree with all their policies, and be able to have members speaking and voting in Congress.

    But the only way any of this can happen is if people stop being so short-sighted about every single election, and stop trying to whip each other into toeing the line of a demonstrably pisspoor party.