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
How many sets of equations (V and M equations) would you need to describe shear and moment as functions of x for this beam? In o
den301095 [7]

Shear and moment as functions of x is described below .

Explanation:

1. Beam is the slender bar that carries transverse

loading; that is, the applied force are perpendicular to the bar.

2. In a beam, the internal force system consist of a shear force and

a bending moment acting on the cross section of the bar.

3. The  shear force and the bending moment usually vary continuously

along the length of the beam.

4. The internal forces give rise to two kinds of stresses on a

transverse section of a beam:

(1) normal stress that is caused by

bending moment and

(2) shear stress due to the shear force.

Knowing the distribution of the shear force and the bending

moment in a beam is essential for the computation of stresses

and deformations.

Shear- Moment Equations

The determination of the internal force system acting at a given

section of a beam : draw a free-body diagram that expose these

forces and then compute the forces using equilibrium equations.

The goal of the beam analysis -determine the shear force  V and  the bending moment  M at every cross section of the beam.

To derive the expressions for  V and M in terms of the distance x

measured along the beam. By plotting these expressions to scale,

obtain the shear force and bending moment diagrams for the

beam.

The shear force and bending moment diagrams are convenient

visual references to the internal forces in a beam; in particular,  they identify the maximum values of  V and  M

5 0
3 years ago
What steps might one take to make a decision or solve a problem
marusya05 [52]

you must think and plan out what you want to do

8 0
3 years ago
Read 2 more answers
If you are driving a 30-foot
Ratling [72]

Answer:

3 sec

If you are driving a 30-foot vehicle at 55 mph, how many seconds of following distance should you allow? 30ft truck. = 3 sec. Since the truck is over 40 mph.

Explanation:

5 0
3 years ago
How do I get my son to do his work?
valentinak56 [21]

Answer:

Explanation:

Reward him if he does his homework/work

If he doesnt do his homework, take things that he loves off of him. and tell him if he does his homework/work he will get them things back

8 0
3 years ago
What is the effect of the workpiece specific cutting energy on the cutting forces, and why?
ella [17]

Explanation:

Specific cutting energy:

   It the ratio of power required to cut the material to metal removal rate of material.If we take the force required to cut the material is F and velocity of cutting tool is V then cutting power will be the product of force and the cutting tool velocity.

Power P = F x V

Lets take the metal removal rate =MRR

Then the specific energy will be

    sp=\dfrac{F\times V}{MRR}

If we consider that metal removal rate and cutting tool velocity is constant then when we increases the cutting force then specific energy will also increase.

8 0
3 years ago
Other questions:
  • According to Manor, the example of the subway train in New York City is an example of which type of uniqueness?
    9·1 answer
  • Consider a voltage v = Vdc + vac where Vdc = a constant and the average value of vac = 0. Apply the integral definition of RMS t
    7·1 answer
  • A banked highway is designed for traffic moving at v = 88 km/h. The radius of the curve r = 314 m. show answer No Attempt 50% Pa
    5·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
  • The air velocity in the duct of a heating system is to be measured by a Pitot-static probe inserted into the duct parallel to th
    13·1 answer
  • Going back the b beginning of the process is common in engineering true or false?
    15·1 answer
  • What are probiotic bacteria and how did Danino and his team use this type of bacteria to detect liver cancer?
    15·1 answer
  • WHAT IS MEANT BY BJT AND FUNCTION OF BJT
    8·1 answer
  • When did michael faraday invent wind powered electrical generation?
    11·1 answer
  • REVVIVE ME MY MOM WALKED IN MY ROOM AND SCARED THE BAJESUS OUTTA ME
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!