ExLisper Site
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
cm0002@lemmy.world to Programmer Humor@programming.dev · 7 days ago

Tell me the truth ...

piefed.jeena.net

message-square
27
fedilink
568

Tell me the truth ...

piefed.jeena.net

cm0002@lemmy.world to Programmer Humor@programming.dev · 7 days ago
message-square
27
fedilink
alert-triangle
You must log in or register to comment.
  • KindaABigDyl@programming.dev
    link
    fedilink
    arrow-up
    74
    ·
    7 days ago
    typedef struct {
        bool a: 1;
        bool b: 1;
        bool c: 1;
        bool d: 1;
        bool e: 1;
        bool f: 1;
        bool g: 1;
        bool h: 1;
    } __attribute__((__packed__)) not_if_you_have_enough_booleans_t;
    
  • midori matcha@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    ·
    6 days ago

    boolean bloat

    • Camelbeard@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      6 days ago

      I first thought you wrote boolean float, not sure if that’s even worse.

      • niktemadur@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        5 days ago

        boolean root beer float

        • Lemminary@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          5 days ago

          deleted by creator

  • Subverb@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    edit-2
    6 days ago

    The 8-bit Intel 8051 family provides a dedicated bit-addressable memory space (addresses 20h-2Fh in internal RAM), giving 128 directly addressable bits. Used them for years. I’d imagine many microcontrollers have bit-width variables.

    bit myFlag = 0;

    Or even return from a function:

    bit isValidInput(unsigned char input) { // Returns true (1) if input is valid, false (0) otherwise return (input >= '0' && input <= '9'); }

    • the_tab_key@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      6 days ago

      We could go the other way as well: TI’s C2000 microcontroller architecture has no way to access a single byte, let alone a bit. A Boolean is stored in 16-bits on that one.

    • jkercher@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      6 days ago

      And, you can have pointers to bits!

  • borokov@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    6 days ago

    Peasant…

    https://github.com/aumuell/open-inventor/blob/014e2bf17f50f5d510cdd57744d03c436ee9ce27/lib/database/include/Inventor/SbBasic.h#L83

  • glitchdx@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    ·
    6 days ago

    if wasting a byte or seven matters to you, then then you need to be working in a lower level language.

  • JakenVeina@lemm.ee
    link
    fedilink
    English
    arrow-up
    10
    ·
    6 days ago

    It’s far more often stored in a word, so 32-64 bytes, depending on the target architecture. At least in most languages.

    • timhh@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      6 days ago

      No it isn’t. All statically typed languages I know of use a byte. Which languages store it in an entire 32 bits? That would be unnecessarily wasteful.

  • pelya@lemmy.world
    link
    fedilink
    arrow-up
    13
    ·
    7 days ago

    std::vector<bool> fits eight booleans into one byte.

    • borokov@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      5 days ago
      auto v = std::vector<bool>(8);
      bool* vPtr = v.data;
      vPtr[2] = true;
      // KABOOM !!!
      

      I’ve spent days tracking this bug… That’s how I learned about bool specialisation of std::vector.

  • Jankatarch@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    5 days ago

    I mean is it really a waste? What’s minimum amount of bits most CPUs read in one cycle.

  • steeznson@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    5 days ago

    We need to be able to express 0 and 1 as integers so that functionality is just being overloaded to express another concept.

    Wait until the person who made this meme finds out about how many bits are being wasted on modern CPU architectures. 7 is the minimum possible wasted bits but it would be 31 on every modern computer (even 64b machines since they default to 32b ints).

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    6 days ago

    pragma(pack) {

    int a:1, b:1, … h:1;

    }

    IIRC.

  • SW42@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    6 days ago

    Joke’s on you, I always use 64 bit wide unsigned integers to store a 1 and compare to check for value.

    • aport@programming.dev
      link
      fedilink
      arrow-up
      4
      ·
      6 days ago

      So does the cpu

  • Skullgrid@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    6 days ago

    just like electronic components, they sell the gates by the chip with multiple gates in them because it’s cheaper

    • JakenVeina@lemm.ee
      link
      fedilink
      English
      arrow-up
      2
      ·
      6 days ago

      That’s a good analogy.

  • ZeroGravitas@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    6 days ago

    7 Shades of Truth

  • UnfortunateShort@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    6 days ago

    Wait till you realise the size of SSD sectors

  • Ice@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    6 days ago

    …or you can be coding assembler - it’s all just bits to me

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 228 users / day
  • 1.34K users / week
  • 2.66K users / month
  • 4.72K users / 6 months
  • 1 local subscriber
  • 23.4K subscribers
  • 295 Posts
  • 977 Comments
  • Modlog
  • mods:
  • adr1an@programming.dev
  • Feyter@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.10
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org