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
What is the function of a regulator?
elena55 [62]
The function if I’m not correct just text me but 3
3 0
2 years ago
Which step in the engineering design phase is requiring concussion prevention from blows up to 40 mph an example of?
Charra [1.4K]

Answer:

Target your customers

Explanation:

took the test :)

6 0
2 years ago
What can your employer do to protect you from overhead power lines?
agasfer [191]

Answer:

Have the power company install insulated sleeves (also known as “eels”) over power lines.​

Wearing PPE is the only way to prevent being electrocuted

Explanation:

To prevent electrocution at workplace, employers can ensure that the  power company install insulated sleeves (also known as “eels”) over power lines.​ Additionally, the employees should wear PPEs which are insulators to prevent electrocution.

5 0
3 years ago
What is the function rule for the line? f(x)=−32x−2f(x)=−23x−2f(x)=32x−2f(x)=−32x+2A coordinate grid with x and y axis ranging f
murzikaleks [220]

Answer:

f(x)=23x−2

Explanation:

still trying to figure that out

7 0
3 years ago
A 1000 W iron utilizes a resistance wire which is 20 inches long and has a diameter of 0.08 inches. Determine the rate of heat g
SSSSS [86.1K]

Answer:

The rate of heat generation in the wire per unit volume is 5.79×10^7 Btu/hrft^3

Heat flux is 9.67×10^7 Btu/hrft^2

Explanation:

Rate of heat generation = 1000 W = 1000/0.29307 = 3412.15 Btu/hr

Area (A) = πD^2/4

Diameter (D) = 0.08 inches = 0.08 in × 3.2808 ft/39.37 in = 0.0067 ft

A = 3.142×0.0067^2/4 = 3.53×10^-5 ft^2

Volume (V) = A × Length

L = 20 inches = 20 in × 3.2808 ft/39.37 in = 1.67 ft

V = 3.53×10^-5 × 1.67 = 5.8951×10^-5 ft^3

Rate of heat generation in the wire per unit volume = 3412.15 Btu/hr ÷ 5.8951×10^-5 ft^3 = 5.79×10^7 Btu/hrft^3

Heat flux = 3412.15 Btu/hr ÷ 3.53×10^-5 ft^2 = 9.67×10^7 Btu/hrft^2

3 0
2 years ago
Other questions:
  • To ensure safe footing on penetrable surfaces,use?
    5·1 answer
  • The internal loadings at a critical section along the steel drive shaft of a ship are calculated to be a torque of 2300 lb⋅ft, a
    8·1 answer
  • Why is it a good idea to lock your doors while driving?<br> WRITER
    10·1 answer
  • Air at 20 C and 1 atm flows over a flat plate at 35 m/s. The plate is 75 cm long and is maintained at 60 с. Assuming unit depth
    8·1 answer
  • Your coworker was impressed with the efficiency you showed in the previous problem and would like to apply your methods to a pro
    5·1 answer
  • What causes decay in the amplitudes of vibration?
    11·1 answer
  • WHAT IS MEANT BY BJT AND FUNCTION OF BJT
    8·1 answer
  • Which option identifies the type of engineering technician most likely to be involved in the following scenario?
    9·1 answer
  • A golfer and her caddy see lightning nearby. the golfer is about to take his shot with a metal club, while her caddy is holding
    12·1 answer
  • What is the creative process that helps you overcome writer's block called?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!