Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the next 3 problems, calculate how many seconds from Noon, August 24 2017 un

ID: 2246933 • Letter: F

Question

For the next 3 problems, calculate how many seconds from Noon, August 24 2017 until the start of the next total solar eclipse in the continental USA on April 8, 2024 in Dallas, TX. How many bits are required to store this number of seconds as an unsigned integer? How many mantissa and exponent bits are required to store this same time period, but in YEARS as a float, without data loss? Use "excess zero" value for your float format. That is, do not add any excess value to the exponent. How many mantissa and exponent bits are required to store this same time period, but in DAYS as a float, without data loss? Use "excess zero" value for your float format.

Explanation / Answer

From August 24, 2017 to April 8, 2024, there are 2419 days which correspond to 2419*24*60*60 = 209001600 seconds.

38) 209001600 seconds correspond to 1100011101010001110010000000 in binary which means it consists of 32 bits. Hence, your answer is 32 bits.

39) Mantissa bits = 32 and Exponent bits = 32 since the float value comes out to be 6.62739726(decimal value) since the corresponding binary values are: Mantissa = 100111100000001001101100001110 and Exponent = 11101111010101010100001110

40) Mantissa bits = 21 and Exponent bits = 0 since the float value comes out to be 2419 days(decimal value) which in binary is 0000100101110011

The following is a sample program which will give you an idea how to calculate no. of bits in a given binary. Though it is for a particular number, the input can be dynamically made by suitable modifications.

unsigned int countSetBits(unsigned int n)

{

  unsigned int count = 0;

  while(n)

  {

    count += n & 1;

    n >>= 1;

  }

  return count;

}

/* Program to test function countSetBits */

int main()

{

    int i = 9;

    printf("%d", countSetBits(i));

    getchar();

    return 0;

}