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
What are the disadvantages of having a liquid cooled engine?
Feliz [49]
One notable disadvantage of liquid cooling over air cooling is that it is considerably costly to set up. Cooling fans are prevalent in the market, and this overabundance of supply means they are cheap. The components of a liquid cooling system can be expensive.
5 0
2 years ago
Air exits a compressor operating at steady-state, steady-flow conditions at 150 oC, 825 kPa, with a velocity of 10 m/s through a
ioda

Answer:

a) Qe = 0.01963 m^3 / s , mass flow rate m^ = 0.1334 kg/s

b) Inlet cross sectional area = Ai = 0.11217 m^2 , Qi = 0.11217 m^3 / s    

Explanation:

Given:-

- The compressor exit conditions are given as follows:

                  Pressure ( Pe ) = 825 KPa

                  Temperature ( Te ) = 150°C

                  Velocity ( Ve ) = 10 m/s

                  Diameter ( de ) = 5.0 cm

Solution:-

- Define inlet parameters:

                  Pressure = Pi = 100 KPa

                  Temperature = Ti = 20.0

                  Velocity = Vi = 1.0 m/s

                  Area = Ai

- From definition the volumetric flow rate at outlet ( Qe ) is determined by the following equation:

                   Qe = Ae*Ve

Where,

           Ae: The exit cross sectional area

                   Ae = π*de^2 / 4

Therefore,

                  Qe = Ve*π*de^2 / 4

                  Qe = 10*π*0.05^2 / 4

                  Qe = 0.01963 m^3 / s

 

- To determine the mass flow rate ( m^ ) through the compressor we need to determine the density of air at exit using exit conditions.

- We will assume air to be an ideal gas. Thus using the ideal gas state equation we have:

                   Pe / ρe = R*Te  

Where,

           Te: The absolute temperature at exit

           ρe: The density of air at exit

           R: the specific gas constant for air = 0.287 KJ /kg.K

             

                ρe = Pe / (R*Te)

                ρe = 825 / (0.287*( 273 + 150 ) )

                ρe = 6.79566 kg/m^3

- The mass flow rate ( m^ ) is given:

               m^ = ρe*Qe

                     = ( 6.79566 )*( 0.01963 )

                     = 0.1334 kg/s

- We will use the "continuity equation " for steady state flow inside the compressor i.e mass flow rate remains constant:

              m^ = ρe*Ae*Ve = ρi*Ai*Vi

- Density of air at inlet using inlet conditions. Again, using the ideal gas state equation:

               Pi / ρi = R*Ti  

Where,

           Ti: The absolute temperature at inlet

           ρi: The density of air at inlet

           R: the specific gas constant for air = 0.287 KJ /kg.K

             

                ρi = Pi / (R*Ti)

                ρi = 100 / (0.287*( 273 + 20 ) )

                ρi = 1.18918 kg/m^3

Using continuity expression:

               Ai = m^ / ρi*Vi

               Ai = 0.1334 / 1.18918*1

               Ai = 0.11217 m^2          

- From definition the volumetric flow rate at inlet ( Qi ) is determined by the following equation:

                   Qi = Ai*Vi

Where,

           Ai: The inlet cross sectional area

                  Qi = 0.11217*1

                  Qi = 0.11217 m^3 / s    

- The equations that will help us with required plots are:

Inlet cross section area ( Ai )

                Ai = m^ / ρi*Vi  

                Ai = 0.1334 / 1.18918*Vi

                Ai ( V ) = 0.11217 / Vi   .... Eq 1

Inlet flow rate ( Qi ):

                Qi = 0.11217 m^3 / s ... constant  Eq 2

               

6 0
3 years ago
A 200‑m rigid vessel contains a saturated liquid‑vapor mixture with a vapor quality of 75%. The temperature of the vessel is mai
DerKrebs [107]

Answer:

Given,

Temperature;

T = 393;;K

Convert to Celcius;

T = (393-273) degrees

T = 120°C

Using Table A-4 (Saturated water - Temperature table), at T = 120 C;

vf = 0.001060 m³/kg

vg = 0.89133 m³/kg

Quality is given as;

75% = 0.75

Specific volume is given as;

v = vf + x (vg - vf) = 0.001060 + 0.75(0.89133 _ 0.001060)

v= 0.66876 m³/kg

We know;

v = V/m

0.66876  = 100/m

m = 149.53 kg

6 0
3 years ago
Do you know anything about Android graphics?
Mashutka [201]

Android provides a huge set of 2D-drawing APIs that allow you to create graphics.

Android has got visually appealing graphics and mind blowing animations.

The Android framework provides a rich set of powerful APIS for applying animation to UI elements and graphics as well as drawing custom 2D and 3D graphics.

<h3>Three Animation Systems Used In Android Applications:-</h3>

1. Property Animation

2. View Animation

3. Drawable Animation

7 0
2 years ago
Repetitive movements at work can lead to injuries. True or False
OverLord2011 [107]
Answer

True

Explanation

RSI can occur when you do repetitive movements. Those movements can cause your muscles and tendons to become damaged over time. Some activities that can increase your risk for RSI are: stressing the same muscles through repetition.
8 0
2 years ago
Other questions:
  • The correct statement about the lift and drag on an object is:_______
    7·2 answers
  • An engineer is considering time of convergence in a new Layer 3 environment design. Which two attributes must be considered? (Ch
    15·1 answer
  • A hydraulic cylinder has a 125-mm diameter piston with hydraulic fluid inside the cylinder and an ambient pressure of 1 bar. Ass
    8·1 answer
  • The acceleration of a point is given. a = 20 t m/s2 When t=0, s = 50 m and v = -8 m/s. What are the position and velocity of the
    13·1 answer
  • 0.9 lbm of water fills a container whose volume is 1.9 ft3. The pressure in the container is 100 psia. Calculate the total inter
    9·1 answer
  • Define the terms (a) thermal conductivity, (b) heat capacity and (c) thermal diffusivity
    11·1 answer
  • You must yield the right-of-way to all of the following EXCEPT:
    8·1 answer
  • a poorly tighten terminal is often the cause of a/an ? a) open circuit b) circuit breaker interrupt c)short circuit d) ground fa
    10·1 answer
  • Who was the American founder and leader of the Shakers in the 1770’s who advocated equality, individual responsibility, and peac
    11·2 answers
  • Dampness or moisture introduces ____ into the weld, which causes cracking when some metals are welded.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!