1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Daniel [21]
3 years ago
11

suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign

c function, which will return an unsigned value in which byte i of argument x has been replaced by byte b:unsigned replace_byte (unsigned x, int i, unsigned char b);
Engineering
1 answer:
sammy [17]3 years ago
8 0

Solution:

typedef  unsigned  char  *byte_pointer;

static int  int_of_bit  (byte_pointer x,  int  loc)

{

                  return(x[loc] << loc*8);

}  

static int  replace_byte(unsigned int a,  int loc,  unsigned int  b)

    unsigned int a_loc = int_of_bit((byte_pointer) &a ,  loc);

    unsigned int b_loc = (b  <<  loc*8);

 

     a  -=  a_loc;

      a  += b_loc;

      return a;

}

Explanation:

This takes two ints in hex format, one with 8 bits (0x00000000) and one with 2 bits (0x00) then places the 2 bit hex into the 8 bit at a given location.

EX:  replace_byte(0x00000000, 1, 0xFF) return 0x0000FF00

First thing first, it looks like you have some mixup:

" one with 8 bits (0x00000000) and one with 2 bits (0x00)*- what you mean is nibble not bits. Each hex character (0-9, A-F) represent 4 bits (16 possible combination), and is called a "nibble".

0x0000000 is 4 bytes. 0x00 is 2 bytes.

Next, you say "takes two ints in hex format" - your function takes two ints in any format. You're just choosing tp express them in hexidecimal. C++ doesn't care if you specify numbers in hex, decimal, octal, binary, etc.

You might be interested in
2. When it comes to selling their crop, what are 3 options a farmer has when harvesting their grain?
tiny-mole [99]

Answer:

Sell his crop, use his crop as food, and sell his crop

Explanation:

6 0
3 years ago
(a) For a given material, would you expect the surface energy to be greater than, the same as, or less than the grain boundary e
aksik [14]

Answer:

(a) Surface energy is greater than grain boundary energy due to the fact that the bonds of the atoms on the surface are lower than those of the atoms at the grain boundary. The energy is also directly proportional to the number of bonds created.

(b) The energy of a high-angle grain boundary is higher than that of a small-angle grain boundary because the high-angle grain boundary has a higher misalignment and smaller number of bonds than a small-angle grain boundary.

Explanation:

(a) Surface energy is greater than grain boundary energy due to the fact that the bonds of the atoms on the surface are lower than those of the atoms at the grain boundary. The energy is also directly proportional to the number of bonds created.

(b) The energy of a high-angle grain boundary is higher than that of a small-angle grain boundary because the high-angle grain boundary has a higher misalignment and smaller number of bonds than a small-angle grain boundary.

5 0
3 years ago
If a 9V battery produces a current of 3 A through a load, what is the resistance of the load
Elden [556K]

3 ohms hope this helps :D ❤

7 0
3 years ago
Read 2 more answers
Bind hole, 38 diameter, .50 deep
agasfer [191]

Answer:

59.69021

Explanation:

38/.5 x 3.14159

4 0
2 years ago
Many households in developing countries prepare food over indoor cook stoves with no ducting system to exhaust the combustion pr
lorasvet [3.4K]

Answer:

   C = 0.22857 ng / m³

Explanation:

Let's solve this problem for part the total time in the kitchen is

          t = 2h (60 min / 1h) = 120 min

The concentration (C) quantity of benzol pyrene is the initial quantity plus the quantity generated per area minus the quantity eliminated by the air flow. The amount removed can be calculated assuming that an amount of extra air that must be filled with the pollutant

amount generated

         C = co + time_generation rate / (area_house + area_flow)

         C = 0.2 + 0.01 120 / (40+ 2)

         C = 0.22857 ng / m³

7 0
3 years ago
Other questions:
  • A strip of AISI 304 stainless steel, 2mm thick by 3cm wide, at 550°C, continuously enters a cooling chamber that removes heat at
    12·1 answer
  • 10. What does a profile of a river from its headwaters to its mouth typically show?
    13·1 answer
  • The Bureau of Labor and Statistics predicted that the field of biomedical engineering would increase by 62 percent over the comi
    5·1 answer
  • Heating of Oil by Air. A flow of 2200 lbm/h of hydrocarbon oil at 100°F enters a heat exchanger, where it is heated to 150°F by
    7·1 answer
  • What is kinetic energy?
    5·2 answers
  • What parts do all circuits have in common?
    9·2 answers
  • Harlin is designing a new car engine that does not create pollution. Which technological design factor is probably the most
    8·1 answer
  • Explain what the engineering team should advise in the following scenario.
    7·1 answer
  • which acpi power state allows a system to start where it left off, but all other components are turned off? sleeping mechanical
    13·1 answer
  • The section of the area to be examined is shown circumscribed by broken lines with circles at
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!