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
The three resistors in the circuit shown have values of 4ohms 4ohms and 2ohms. The battery has a value of 12 volts. What is the
gtnhenbr [62]

Answer:

2ohms

Explanation:

3 0
3 years ago
Which term describes a Cloud provider allowing more than one company to share or rent the same server?
svlad2 [7]

Answer:

multitenancy is the term.

6 0
3 years ago
The purpose of pasteurizing milk is to
katen-ka-za [31]

Answer:

i think it c

Explanation:

6 0
3 years ago
Read 2 more answers
A ductile hot-rolled steel bar has a minimum yield strength in tension and compression of Syt = 60 kpsi and Syc = 75 kpsi. Using
kow [346]

Answer:

2.135

Explanation:

Lets make use of these variables

Ox 16.5 kpsi, and Oy --14,5 kpsi

To determine the factor of safety for the states of plane stress. We have to first understand the concept of Coulomb-Mohr theory.

Mohr–Coulomb theory is a mathematical model describing the response of brittle materials such as concrete, or rubble piles, to shear stress as well as normal stress.

Please refer to attachment for the step by step solution.

4 0
4 years ago
What are the advantages of triggering circuit<br> for thyrestors?
sergejj [24]

Answer:

For most applications, it is simple, dependable, efficient, and straightforward to apply - a simple trigger signal may be provided, with appropriate processing if necessary. This implies that an appropriate trigger signal may be generated using other electrical circuits and then applied to the SCR.

Explanation:

3 0
3 years ago
Other questions:
  • Consider a fan located in a 3 ft by 3 ft square duct. Velocities at various points at the outlet are measured, and the average f
    12·1 answer
  • Show how am MDP with a reward function R(s, a, s’) can be transformed into a different MDP with reward function R(s, a), such th
    15·1 answer
  • An engineer is working with archeologists to create a realistic Roman village in a museum. The plan for a balance in a marketpla
    9·1 answer
  • Blank Complete the following paragraph pertaining to the popular audio file formats.
    7·2 answers
  • Generally natural shape of stone is in shaped as (a)angular (b)irregular (c)cubical cone shape (d)regular
    10·2 answers
  • 3. Which of the following is not a common impact
    7·1 answer
  • A flywheel made of Grade 30 cast iron (UTS = 217 MPa, UCS = 763 MPa, E = 100 GPa, density = 7100 Kg/m, Poisson's ratio = 0.26) h
    9·1 answer
  • The bulk density of a compacted soil specimen (Gs = 2.70) and its water content are 2060 kg/m^3 and 15.3%, respectively. If the
    5·1 answer
  • To do you blur text in google docs
    10·1 answer
  • What is definition of<br>computational fluid Dynamics <br>unstructured grid <br>domain<br>geometry​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!