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 rectangular block of material with shear modulus G= 620 MPa is fixed to rigid plates at its top and bottom surfaces. Thelower
PIT_PIT [208]

Answer:

γ_{xy} =0.01, P=248 kN

Explanation:

Given Data:

displacement = 2mm ;

height = 200mm ;

l = 400mm ;

w = 100 ;

G = 620 MPa = 620 N//mm²;    1MPa = 1N//mm²

a. Average Shear Strain:

The average shear strain can be determined by dividing the total displacement of plate by height

γ_{xy} = displacement / total height

     = 2/200 = 0.01

b. Force P on upper plate:

Now, as we know that force per unit area equals to stress

τ = P/A

Also,  τ = Gγ_{xy}

By comapring both equations, we get

P/A = Gγ_{xy}   ------------ eq(1)

First we need to calculate total area,

A = l*w = 400 * 100= 4*10^4mm²

By putting the values in equation 1, we get

P/40000 = 620 * 0.01

P = 248000 N or 2.48 *10^5 N or 248 kN

6 0
3 years ago
Shortly after the introduction of a new​ coin, newspapers published articles claiming the coin is biased. The stories were based
garik1379 [7]

Answer:

(a) 0.12924

(b) Taking into consideration significance level of 0.05 yet the value of p is greater than 0.05, it suggests that the coin is fair hence the coin can be used at the beginning of any sport event.

Explanation:

(a)

n=200 for fair coin getting head, p= 0.5

Expectation = np =200*0.5=100

Variance = np(1 - p) = 100(1-0.5)=100*0.5=50

Standard deviation, s = \sqrt {variance}=\sqrt {50}= 7.071068

Z value for 108, z =\frac {108-100}{7.071068}= 1.131371

P( x ≥108) = P( z >1.13)= 0.12924

(b)

Taking into consideration significance level of 0.05 yet the value of p is greater than 0.05, it suggests that the coin is fair hence the coin can be used at the beginning of any sport event.

3 0
3 years ago
he circular stream of water from a faucet is observed to taper from a diameter of 21 mm to 12 mm in a distance of 52 cm. Determi
Gemiola [76]

Answer: 1.52 × 10^{-3} \frac{m^{3} }{s}

Explanation:

Please kindly find the attached document for the answer.

5 0
3 years ago
What are the different types of documents used to communicate engineering designs?
Ipatiy [6.2K]

Answer:

COMMON ENGINEERING DOCUMENTS

Inspection or trip reports.

Research, laboratory, and field reports.

Specifications.

Proposals.

Progress reports.

ect...

Explanation:

7 0
3 years ago
THE COMPUND INTEREST ON RS 30,000AT 7% PER ANNUM IS RS 4347 THE PERIOD IN YEARS
timofeeve [1]

Answer:

what wym

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Consider a single crystal of some hypothetical metal that has the BCC crystal structure and is oriented such that a tensile stre
    10·1 answer
  • Three tool materials (high-speed steel, cemented carbide, and ceramic) are to be compared for the same turning operation on a ba
    10·1 answer
  • The mass flow rate in a 4.0-m wide, 2.0-m deep channel is 4000 kg/s of water. If the velocity distribution in the channel is lin
    5·1 answer
  • : A pneumatic "cannon" is a device that launches a low mass projectile from a cylindrical tube using pressurized air stored upst
    6·1 answer
  • What does the word “robot” mean? A.Clone B. Athlete C. Servant D. Actor
    11·1 answer
  • The density of a certain material is such that it weighs 9 pounds per cubic foot of
    10·1 answer
  • 6
    5·1 answer
  • The 10mm diameter rod is made of Kevlar 49. Determine the change in
    7·1 answer
  • Which of the following explains why trucking is the most widely used transportation method?
    14·1 answer
  • 14. An engine is brought into the shop with a
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!