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
A coal-burning power plant generates electrical power at a rate of 650 megawatts (MW), or 6.50 × 108 J/s. The plant has an overa
Vinvika [58]

Answer:

Energy produce in one year =20.49 x 10¹⁶ J/year

Explanation:

Given that

Plant produce 6.50 × 10⁸ J/s of energy.

It produce  6.50 × 10⁸ J in 1 s.

We know that

1 year = 365 days

1 days = 24 hr

1 hr = 3600 s

1 year = 365 x 24 x 3600 s

1 year = 31536000 s

So energy produce in 1 year = 31536000 x  6.50 × 10⁸ J/year

          Energy produce in one year = 204984 x 10¹² J/year

          Energy produce in one year =20.49 x 10¹⁶ J/year

7 0
3 years ago
While discussing what affects the amount of pressure exerted by the brakes: Technician A says that the shorter the line, the mor
harina [27]

Answer:

Only Technician B is right.

Explanation:

The cylindrical braking system for a car works through the mode of pressure transmission, that is, the pressure applied to the brake pedals, is transmitted to the brake pad through the cylindrical piston.

Pressure applied on the pedal, P(pedal) = P(pad)

And the Pressure is the applied force/area for either pad or pedal. That is, P(pad) = Force(pad)/A(pad) & P(pedal) = F(pedal)/A(pedal)

If the area of piston increases, A(pad) increases and the P(pad) drops, Meaning, the pressure transmitted to the pad reduces. And for most cars, there's a pressure limit for the braking system to work.

If the A(pad) increases, P(pad) decreases and the braking force applied has to increase, to counter balance the dropping pressure and raise it.

This whole setup does not depend on the length of the braking lines; it only depends on the applied force and cross sectional Area (size) of the piston.

5 0
3 years ago
A fatigue test was conducted in which the mean stress was 90 MPa (13050 psi), and the stress amplitude was 190 MPa (27560 psi).
Gwar [14]

Answer:

a) 280MPa

b) -100MPa

c) -0.35

d) 380 MPa

Explanation:

GIVEN DATA:

mean stress \sigma_m = 90MPa

stress amplitude \sigma_a = 190MPa

a) \sigma_m =\frac{\sigma_max+\sigma_min}{2}

    90 =\frac{\sigma_{max}+\sigma_{min}}{2} --------------1

\sigma_a =\frac{\sigma_{max}-\sigma_{min}}{2}

   190 = \frac{\sigma_{max}-\sigma_{min}}{2} -----------2

solving 1 and 2 equation we get

\sigma_{max} = 280MPa

b) \sigma_{min} = - 100MPa

c)

stress ratio=\frac{\sigma_{min}}{\sigma_{max}}

=\frac{-100}{280} = -0.35

d)magnitude of stress range

                      =(\sigma_{max} -\sigma_{min})

                       = 280 -(-100) = 380 MPa

3 0
3 years ago
Select the correct answer.
Elodia [21]
I think balance




Can I get Brainlyist
3 0
3 years ago
Which is an example of a passive solar energy system
Dafna1 [17]
Stone or concrete contraptions
5 0
3 years ago
Other questions:
  • Fatigue failure occurs under the condition of (a) High elastic stress (b) High corrosivity (c) High stress fluctuations (d) High
    9·1 answer
  • A disk brake has two pads which cover 45 degrees of the disk. The outside radius is 6.0 inch and the inside radius is 4.0 inch.
    5·1 answer
  • Argon is compressed in a polytropic process with n=1.2 from 120 kPa and 10 °C to 800 kPa in a piston cylinder device. Determine:
    11·1 answer
  • Go online and search for information about companies that have been harmed or bankrupted by a disaster. Choose one such company
    11·1 answer
  • a vehicle is in her repair with a complaint at for heating output during testing and diagnosing air is found to be trapped in th
    15·1 answer
  • Help me i need this bad :)
    14·1 answer
  • Pointssss 100 and brainliest :)
    5·1 answer
  • Giving away free brainliest your welcome​
    15·2 answers
  • 28. What is the value of a resistor in a series circuit if you measure 0.5 amps flowing through it and 15 volts
    10·1 answer
  • A bridge a mass of 800 kg and is able to support up to 4 560 kg. What is its structural efficiency?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!