Battery algorithms



  • What algorithms exist with the use of battlefields initiated in structures?



  • Since this is the case battlefieldsNot battle vectorsa more appropriate example of their use:

    typedef struct
    {
        union
        {
           struct
           {
               unsigned long mantissa: 23;
               unsigned long exponent: 8;
               unsigned long sign: 1;
           } float_parts;
           float all;
        };
    } _float __attribute__((__packed__));
    

    Here, the use of battlefields allows easy access to the inner content of the number according to IEE754 (Of course there are other problems. endiannessbut this is not so principled)

    Previous battlefields (e.g. in the first gambling variations idTech) Used frequently enough to save memory of any data.

    Now their use, in my view, is pointless, and, in general, access to such a structure takes longer because of the need masking'a


    More practically, I recommend that the article be read http://www.gotw.ca/publications/N1211.pdf Which explains how bad it is. vector<bool>

    It's to learn how to use it. std::bitset and boost::dynamic_bitset




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2