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
Select the best answer to the questo
Norma-Jean [14]

Answer:

C

Explanation:

7 0
3 years ago
Read 2 more answers
A thick steel slab ( 7800 kg/m3 , c 480 J/kg K, k 50 W/m K) is initially at 300 C and is cooled by water jets impinging on one o
Nutka1998 [239]

Answer:

1791 secs  ≈ 29.85 minutes

Explanation:

( Initial temperature of slab )  T1 = 300° C

temperature of water ( Ts ) = 25°C

T2 ( final temp of slab ) = 50°C

distance between slab and water jet = 25 mm

<u>Determine how long it will take to reach T2</u>

First calculate the thermal diffusivity

∝  = 50 / ( 7800 * 480 ) = 1.34 * 10^-5 m^2/s

<u>next express Temp as a function of time </u>

T( 25 mm , t ) = 50°C

next calculate the time required for the slab to reach 50°C at a distance of 25mm

attached below is the remaining part of the detailed solution

5 0
3 years ago
2. A well of 0.1 m radius is installed in the aquifer of the preceding exercise and is pumped at a rate averaging 80 liter/min.
hodyreva [135]

Question:

The question is not complete. See the complete question and the answer below.

A well that pumps at a constant rate of 0.5m3/s fully penetrates a confined aquifer of 34 m thickness. After a long period of pumping, near steady state conditions, the measured drawdowns at two observation wells 50m and 100m from the pumping well are 0.9 and 0.4 m respectively. (a) Calculate the hydraulic conductivity and transmissivity of the aquifer (b) estimate the radius of influence of the pumping well, and (c) calculate the expected drawdown in the pumping well if the radius of the well is 0.4m.

Answer:

T = 0.11029m²/sec

Radius of influence = 93.304m

expected drawdown = 3.9336m

Explanation:

See the attached file for the explanation.

8 0
3 years ago
Advantages of using metal
Contact [7]

Answer:

Metals have high melting points thus unlikely to degrade when temperatures increase, they can be fabricated and are cost effective due to availability.

Explanation:

Aluminum is the most abundant in the Earth's crust with good thermal and electric properties. It is soft, malleable ,ductile and lighter making it a vital metal in construction industry. An alloy of copper and tin, bronze is a better connector of heat and electricity ,commonly used in automobile industry for bearings and springs production. Steel a carbon alloy has applications in forging and automotive.

4 0
2 years ago
The 1000-lb elevator is hoisted by the pulley system and motor M. The motor exerts a constant force of 500 lb on the cable. The
klemol [59]

The power that must be supplied to the motor is 136 hp

<u>Explanation:</u>

Given-

weight of the elevator, m = 1000 lb

Force on the table, F = 500 lb

Distance, s = 27 ft

Efficiency, ε = 0.65

Power  = ?

According to the equation of motion:

F = ma

3(500) - 1000 = \frac{1000}{32.2} * a

a = 16.1 ft/s²

We know,

v^2 - u^2 = 2a (S - So)\\\\v^2 - (0)^2 = 2 * 16.1 (27-0)\\\\v = 29.48m/s

To calculate the output power:

Pout = F. v

Pout = 3 (500) * 29.48

Pout = 44220 lb.ft/s

As efficiency is given and output power is known, we can calculate the input power.

ε = Pout / Pin

0.65 = 44220 / Pin

Pin = 68030.8 lb.ft/s

Pin = 68030.8 / 500 hp

     = 136 hp

Therefore, the power that must be supplied to the motor is 136 hp

5 0
3 years ago
Other questions:
  • The denominator of a fraction is 4 more than the numenator. If 4 is added to the numenator and 7 is added to the denominator, th
    15·1 answer
  • The smallest crystal lattice defects is a) cracks b) point defects c) planar defects d) dislocations.
    11·1 answer
  • A stone-filled pit used for waste disposal is commonly referred to as a
    15·1 answer
  • 3) What kind of bridges direct their load along it's curve and into the
    12·1 answer
  • The 40-ft-long A-36 steel rails on a train track are laid with a small gap between them to allow for thermal expansion. Determin
    8·1 answer
  • Cho biết tác dụng chung của các hệ giằng khung ngang nhà công nghiệp nhẹ 1 tầng 1 nhịp.
    13·1 answer
  • A cylindrical 1040 steel rod having a minimum tensile strength of 865 MPa (125,000 psi), a ductility of at least 10%EL, and a fi
    7·1 answer
  • Which is a better hydraulic cross section for an open channel: one with a small or a large hydraulic radius?
    13·1 answer
  • Select the correct answer.
    8·1 answer
  • Please help me. I have no idea what I'm doing.​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!