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
Air is compressed steadily from 100kPa and 20oC to 1MPa by an adiabatic compressor. If the mass flow rate of the air is 1kg/s an
igomit [66]

Answer:

(a). 575 kJ/kg.

(b). 290kw.

Explanation:

We have the following set of information or parameters from the question above;

Pressure(1) = 100kPa, Pressure (2) = 1MPa, temperature(1) = b1= 12°C = 285K = 285kJ/kg, efficiency = 80% and the mass flow rate of the air = 1kg/s.

At a temperature of 12°C, we have the value from steam table; gx= 1.2, thus gx22 = 1.2 × (1000/100) = 12.

We have that the value for b12 = 517.

Therefore, the value for h2a can be calculated as;

80/100 = (517 - 285)/ (tp at exist) - 285.

0.8 = 232/ (tp at exist) - 285.

232 = 0.8 × (tp at exist) - 285).

232 = 0.8 (tp at exist) - 228 .

(tp at exist) = 575.

Therefore, the temperature 575 kJ/kg.

Thus, the required power input of the compressor = 1kg/s × ( 575 - 285) = 290kw.

6 0
3 years ago
When is a handrail required for stairs?
Leviafan [203]

Answer:

after 8 stepshddnffuddbnggkbdbkloyr

5 0
3 years ago
Describe the cycle that purifies drinking water. 40 points
Sunny_sXe [5.5K]
Umm the Water cycle sorry I’m trying
5 0
3 years ago
Read 2 more answers
What are the relative volume requirements for a CM reactor compared to a PF reactor if first-order kinetics apply and treatment
Tanzania [10]

Answer:

look it up

Explanation:

6 0
3 years ago
1. When jump starting a car, make sure it is in __________.
____ [38]

Answer:

Make sure both cars are in park or neutral with the parking brake engaged. This makes sure that all electrical functions (headlights, radios, etc.) are turned off.

8 0
3 years ago
Other questions:
  • Compute the strain-hardening exponent (n) for an alloy in which a true stress of 415 MPa produces a true strain of 0.10; assume
    10·1 answer
  • Analysis of the relationship between the fuel economy​ (mpg) and engine size​ (in liters) for 35 models of cars produces the reg
    15·1 answer
  • dentify a semiconducting material and provide the value of its band gap) that could be used in: (a) (1 point) red LED (b) (1 poi
    10·1 answer
  • Which tool is used for cutting bricks and other masonry materials with precision?
    12·1 answer
  • How are you today First to awnser is brainlyest.
    6·1 answer
  • Gordon Gould has been forced to fight for his claim to the invention of the laser because:_________.a. he was forced out of the
    8·1 answer
  • What are the coventional representative of automation
    15·1 answer
  • What is the role of engineers in nation building <br><br>​
    13·2 answers
  • How is electricity made from fossil fuels such as coal?.
    10·1 answer
  • A 100-horsepower, three-phase squirrel-cage induction motor is connected to a 240-volt line. A dual-element time-delay fuse is t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!