Question: Write a C++ program called scientificFloating.cpp that reads in a floating point number and outputs its scientific base 2 format. Example 1: Please enter a
Write a C++ program called scientificFloating.cpp that reads in a floating point number and outputs its scientific base 2 format.
Example 1:
Please enter a float: 3.75
1.111E1
Example 2:
Please enter a float: 140.1 1.0001100000110011001101E7
You should use bitwise operators to pick out the fields that you need to work with.
In order to do the appropriate bitwise operations on the float it must first be cast to an int but
(int) f (assuming f is the variable you have stored you float in) will not work as the cast will convert the float representation to the 2's compliment integer representation. The fix is to take the address of the float, cast it as an unsigned int*, and then dereference ? unsigned int float_int = *((unsigned int*)&f);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
