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
Which of the following procedures best applies to assessing the embodied energy of a building?
galina1969 [7]

analyzing building materials???????????? but i can try i think it is analyzing the materials of the building

5 0
3 years ago
An asbestos pad is square in cross section, measuring 5 cm on a side at its small end increasing linearly to 10 cm on a side at
polet [3.4K]

Answer:

q = 1.73 W

Explanation:

given data

small end  = 5 cm

large end = 10 cm

high = 15 cm

small end is held = 600 K

large end at = 300 K

thermal conductivity of asbestos  = 0.173 W/mK

solution

first we will get here side of cross section that is express as

S = S1 + \frac{S2-S1}{L} x     ...............1

here x is distance from small end and S1 is side of square at small end

and S2 is side of square of large end and L is length

put here value and we get

S = 5 + \frac{10-5}{15} x

S = \frac{0.15 + x}{3}    m

and  

now we get here Area of section at distance x is

area A = S²    ...............2

area A = (\frac{0.15 + x}{3})^2    m²

and

now we take here small length dx and temperature difference is dt

so as per fourier law

heat conduction is express as

heat conduction q = \frac{-k\times A\  dt}{dx}      ...............3

put here value and we get

heat conduction q = -k\times (\frac{0.15 + x}{3})^2 \   \frac{dt}{dx}  

it will be express as

q \times \frac{dx}{(\frac{0.15 + x}{3})^2} = -k (dt)  

now we intergrate it with limit 0 to 0.15 and take temp 600 to 300 K

q \int\limits^{0.15}_0 {\frac{dx}{(\frac{0.15 + x}{3})^2 } = -0.173 \int\limits^{300}_{600} {dt}          

solve it and we get

q (30)  = (0.173) × (600 - 300)

q = 1.73 W

5 0
3 years ago
(SI units) Molten metal is poured into the pouring cup of a sand mold at a steady rate of 400 cm3/s. The molten metal overflows
maxonik [38]

Answer:

diameter of the sprue at the bottom is 1.603 cm

Explanation:

Given data;

Flow rate, Q = 400 cm³/s

cross section of sprue: Round

Diameter of sprue at the top d_{top} = 3.4 cm

Height of sprue, h = 20 cm = 0.2 m

acceleration due to gravity g = 9.81 m/s²

Calculate the velocity at the sprue base

V_{base} = √2gh

we substitute

V_{base} = √(2 × 9.81 m/s² × 0.2 m )

V_{base} = 1.98091 m/s

V_{base} = 198.091 cm/s

diameter of the sprue at the bottom will be;

Q = AV = (πd_{bottom}^2/4) × V_{base}

d_{bottom} = √(4Q/πV_{base})

we substitute our values into the equation;

d_{bottom} = √(4(400 cm³/s) / (π×198.091 cm/s))

d_{bottom}  = 1.603 cm

Therefore, diameter of the sprue at the bottom is 1.603 cm

6 0
3 years ago
Openings around pipes that enter building should be covered by
algol [13]

Answer: I have 2 suggestions: one, maybe, maybe, use some of that metal tape that you get at hardware places, and: two, buy a new pipe (or pipes), two be sure that it won't happen again. Have a good day, and thanks for asking the brain!

Explanation:

7 0
3 years ago
​What should be a concern as a weldment becomes larger as more parts are added?
Ludmilka [50]
Shhdudhgfhycvbbgvfhfkyfvjhv
7 0
3 years ago
Other questions:
  • Main technologies used in atms vending machines game consoles and microwave ovens
    6·1 answer
  • Can glasses be formed using metallic materials?​
    6·1 answer
  • Refers to the capability to keep moving forward on a specified grade.
    5·1 answer
  • An alternating current E(t) =120 sin(12t) has been running through a simple circuit for a long time. The circuit has an inductan
    6·1 answer
  • _______ is a material property that pertains to local resistance to plastic deformation, such as scratching or denting. It is of
    10·1 answer
  • Which type of irrigation conserves more water than other types of irrigation?
    8·1 answer
  • Identify the phase of the design process illustrated in the following scenario, and justify its importance. Kristin has recently
    9·1 answer
  • Pls help me answer my module
    13·1 answer
  • A town is designing a rectangular, 4m deep settling tank for treating surface water intake. The tank will have a flow velocity o
    14·1 answer
  • 53. The plan of a building is in the form of a rectangle with
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!