• ZILtoid1991@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    21 hours ago

    That’s why I primarily use booleans in return parameters, beyond that I’ll try to use bitfields. My game engine’s tilemap format uses a 32 bit struct, with 16 bit selecting the tile, 12 bit selecting the palette, and 4 bit used for various bitflags (horizontal and vertical mirroring, X-Y axis invert, and priority bit).

    • acockworkorange@mander.xyz
      link
      fedilink
      arrow-up
      28
      ·
      21 hours ago

      Bit fields are a necessity in low level networking too.

      They’re incredibly useful, I wish more people made use of them.

      I remember I interned at a startup programming microcontrollers once and created a few bitfields to deal with something. Then the lead engineer went ahead and changed them to masked ints. Because. The most aggravating thing is that an int size isn’t consistent across platforms, so if they were ever to change platforms to a different word length, they’d be fucked as their code was full of platform specific shenanigans like that.

      /rant