Question: Background In this question, you will define Binary ToDouble, taking a single std: : string value passed by const reference, and returning a double. The

 Background In this question, you will define Binary ToDouble, taking asingle std: : string value passed by const reference, and returning a

Background In this question, you will define Binary ToDouble, taking a single std: : string value passed by const reference, and returning a double. The std: : string will encode the floating point value in the same toy format as introduced in the lecture video, and your implementation of BinaryToDouble must return the floating point value it encodes. For example, the std: : string below encodes the floating point value 3.5 : Assignment Prompt Your function must ensure the std: : string passed to Binary ToDouble follows the format we specify, including the " 0b " as the first two characters. The character in - index 2 stores the sign bit, - indices 3-4 store the exponent bits, and - indices 5-8 store the mantissa bits. Therefore, the characters in indices 28 must be either ' ' or ' 1 '. If the std: : string fails to follow the format specified, your function must throw an std: : invalid_argument exception. The exponent is encoded using a bias, so your final exponent must be calculated as an exponential field - bias, where bias is equal to 1. Functions to Implement \( \begin{array}{l}\text { clude "parse_float.hpp" } \\ 3 \\\end{array} \)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!