Files to submit: scientificFloating.cpp Time it took Matthew to complete: ?
• All programs must compile without warnings when using the -Wall and -Werror options
• Submit only the files requested
◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.
◦ Only one of you has to submit there
• Your program must match the output exactly to receive credit.
◦ Make sure that all prompts and output match mine exactly.
◦ Easiest way to do this is to copy and paste them
• All input will be valid unless stated otherwise
• Print all real numbers to two decimal places unless otherwise stated
• The examples provided in the prompts do not represent all possible input you can receive.
• All inputs in the examples in the prompt are underlined
◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
• If you have questions please post them on Piazza
Write a C++ program called scientificFloating.cpp that reads in a floating point number and outputs its scientific base 2 format.
1. Example 1:
Please enter a float: 3.75
1.111E1
2. 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);