Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Files to submit : scientificFloating.cpp Time it took Matthew to complete : 20 minutes All programs must compile without warnings when using the -Wall and

Files to submit: scientificFloating.cpp

Time it took Matthew to complete: 20 minutes

  • 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

  • Your program must match the output exactly to receive credit.

    • Make sure that all prompts and output match mine exactly.

    • The easiest way to do this is to copy and paste them from here. Be careful about non-ASCII character though in the HTML as they can cause some weird problems if you put them in your program.

  • 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 CampusWire

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);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions