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

In C++

In C++ In this question, you will define BinaryToDouble, taking a singlestd: : string value passed by const reference, and returning a double.The std: : string will encode the floating point value in thesame toy format as introduced in the lecture video, and your implementation

In this question, you will define BinaryToDouble, 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 BinaryToDoub le 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: : st ring passed to BinaryToDouble 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: : st ring 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 double BinaryToDouble(std: string bit_string); // BinaryToDouble ("0b0101100")=3.5 // BinaryToDouble ("0b0000000") =0.0 // BinaryToDouble ("0b1000000") =0.0 floatpt-value-comp driver.cc parse_float.hpp parse_float.cc CS 128A+ Editor

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!