answersLogoWhite

0

Both C and C++ allow integer members to be stored into memory spaces smaller than the compiler would ordinarily allow. These space-saving structure members are called bit fields, and their width in bits can be explicitly declared. Gagandeep Singh Bitfields can only be declared inside a structure or a union, and allow you to specify some very small objects of a given number of bits in length. struct { /* field 4 bits wide */ unsigned field1 :4; /* * unnamed 3 bit field * unnamed fields allow for padding */ unsigned :3; /* * one-bit field * can only be 0 or -1 in two's complement! */ signed field2 :1; /* align next field on a storage unit */ unsigned :0; unsigned field3 :6; }full_of_fields; The main use of bitfields is either to allow tight packing of data or to be able to specify the fields within some externally produced data files.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Can you enter data in design view in ms access?

No. Design view is for creating the table and manipulating the fields and the structure of the fields and the table. It is not for entering data. To do that you can go to datasheet view or use a form.


Find at least two passages in the Declaration that use parallelism What is the effect of the parallel structure on the idea of the passage?

From pages 3 thru 29 are examples


What weaponds did the Declaration of Independence use?

the declaration of independence is a piece of paper. it did not use weapons.


What is the use of bit field in structure declaration?

A bit field allows you to assign an arbitrary number of bits to a member. As an example, suppose we wish to implement an R6000 PPN (physical page number). A PPN is a 32-bit value divided up as follows: page frame number (22 bits) unused (3 bits) cache coherency algorithm (3 bits) nonreachable (1 bit) dirty (1 bit) valid (1 bit) global (1 bit) While we could use bitwise logic to determine the state of each bit or group of bits within a 32-bit value, it's always good programming practice to express ideas directly in code. Therefore we want a structure that is exactly 32-bits in length with members that exactly match those of the PPN itself. To achieve this we need to use bit fields: // // All example code based upon Chapter 25.5.5 "Bitfields" of // "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup // struct PPN { // R6000 Physical Page Number unsigned int PFN : 22; // Page Frame Number int : 3; // unused unsigned int CCA : 3; // Cache Coherency Algorithm bool nonreachable : 1; bool dirty : 1; bool valid : 1; bool global : 1; }; Any consumer of this structure need be left in little doubt regarding its purpose. Moreover, the implementer's job is greatly simplified: void part_of_VM_system (PPN& ppn) { if (ppn.dirty) { // contents changed // copy to disc ppn.dirty = 0 ; } } We can also see how much simpler it is to extract information from a structure's bit fields compared to that of a 32-bit value: int get_CCA (const PPN& ppn) { return (int) ppn.CCA; } int get_CCA (unsigned int ppn) { return (int) (ppn>>3)&0x7; }


What are the core fields of linguistics?

The core fields of linguistics include phonetics (the study of speech sounds), phonology (the study of sound patterns), morphology (the study of word structure), syntax (the study of sentence structure), semantics (the study of meaning), and pragmatics (the study of language use in context).


Use the Declaration of Independence in a sentence?

the declaration of independence was signed July 4th


How do you use the word fields in a sentence?

These fields of flowers are stunning.


Does the Declaration of Independence use induction or deduction?

The Declaration of Independence uses DEDUCTIVE thinking


How do you use declaration in a senence?

Declaration is the act of declaring. The Kitten made his declaration that all cats must loved!!! Cats Rule!!!


In which document did Thomas Jefferson use the ideas from the Enlightenment?

The Declaration of Independence.. jrc


Did the military use mine fields in the Korean war?

Yes mine fields where used but they were magnetic mine fields.


Doesn't oiling a hot drill bit change the molecular structure making it brittle and requiring oiling each use thereafter?

In most cases I wouldn't think the bit would get hot enough to change the temper or heat treat of it. When drilling you should always use some kind of cutting oil to aide in the removal of chips and to keep the bit cool.