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
An aquifer has three different formations. Formation A has a thickness of 8.0 m and hydraulic conductivity of 25.0 m/d. Formatio
saveliy_v [14]

Answer:

The horizontal conductivity is 41.9 m/d.

The vertical conductivity is 37.2 m/d.

Explanation:

Given that,

Thickness of A = 8.0 m

Conductivity = 25.0 m/d

Thickness of B = 2.0 m

Conductivity = 142 m/d

Thickness of C = 34 m

Conductivity = 40 m/d

We need to calculate the horizontal conductivity

Using formula of horizontal conductivity

K_{H}=\dfrac{H_{A}K_{A}+H_{A}K_{A}+H_{A}K_{A}}{H_{A}+H_{B}+H_{C}}

Put the value into the formula

K_{H}=\dfrac{8.0\times25+2,0\times142+34\times40}{8.0+2.0+34}

K_{H}=41.9\ m/d

We need to calculate the vertical conductivity

Using formula of vertical conductivity

K_{V}=\dfrac{H_{A}+H_{B}+H_{C}}{\dfrac{H_{A}}{K_{A}}+\dfrac{H_{B}}{K_{B}}+\dfrac{H_{C}}{K_{C}}}

Put the value into the formula

K_{V}=\dfrac{8.0+2.0+34}{\dfrac{8.0}{25}+\dfrac{2.0}{142}+\dfrac{34}{40}}

K_{V}=37.2\ m/d

Hence, The horizontal conductivity is 41.9 m/d.

The vertical conductivity is 37.2 m/d.

3 0
3 years ago
What is a shearing stress? Is there a force resulting from two solids in contact to which is it similar?
Luba_88 [7]

Answer:

Shearing stresses are the stresses generated in any material when a force acts in such a way that it tends to tear off the material.

Generally the above definition is valid at an armature level, in more technical terms shearing stresses are the component of the stresses that act parallel to any plane in a material that is under stress. Shearing stresses are present in a body even if normal forces act on it along the centroidal axis.

Mathematically in a plane AB the shearing stresses are given by

\tau =\frac{Fcos(\theta )}{A}

Yes the shearing force which generates the shearing stresses is similar to frictional force that acts between the 2 surfaces in contact with each other.  

7 0
3 years ago
a vertical cylindrical container is being cooled in ambient air at 25 °C with no air circulation. if the initial temperature of
Sloan [31]

Answer:

the surface heat-transfer coefficient due to natural convection during the initial cooling period.  = 4.93 w/m²k

Explanation:

check attachement for answer explanation

7 0
3 years ago
Read 2 more answers
A reversible compression of 1 mol of an ideal gas in a piston/cylinder device results in a pressure increase from 1 bar to P2 an
Mashutka [201]

Answer:

attached below

Explanation:

6 0
3 years ago
Why would the shear stress be considered as the momentum flux.
oksano4ka [1.4K]

Answer:

A fluid flowing along a flat plate will stick to it at the point of contact

Explanation:

and this is known as the no-slip condition. ... This is the precise reason why shear stress in a fluid can also be interpreted as the flux of momentum.

3 0
2 years ago
Other questions:
  • given the classes above, what output is produced by the following code? meg[] elements ={new Lois(), new Stewie(), new Meg(), ne
    15·1 answer
  • Compute the number of kilo- grams of hydrogen that pass per hour through a 6-mm-thick sheet of palladium having an area of 0.25
    12·1 answer
  • The assembly consists of two blocks A and B, which have a mass of 20 kg and 30 kg, respectively. Determine the distance B must d
    14·2 answers
  • Who is the best musician in Nigeria<br>​
    11·2 answers
  • A hot plate with a temperature of 60 C, 50 triangular profile needle wings of length (54 mm), diameter 10 mm (k = 204W / mK) wil
    6·1 answer
  • A Carnot heat engine absorbs 235 KW of heat from a heat source and rejects 164 KW to the atmosphere. Determine the thermal effic
    7·1 answer
  • A student is building a circuit which material should she use for the wires and why?
    10·2 answers
  • PLZZZZZ HELP
    10·2 answers
  • What are the disadvantages of military shovels?
    12·1 answer
  • A logic circuit with 3 gates and 2 inputs. The circuit will be read from the final output to the inputs.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!