Saturday, 22 February 2020

Chapter 11 // Drill 9 - Principles & Practice Using C++

In this exercise I am using Visual Studio Community 2017 and the header file "std_lib_facilities.h" which can be found here:

http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h

Chapter 11 // Drill 9

Write some code to print the number 1234567.89 three times, first using defaultfloat, then fixed, then scientific forms. Which output form presents the user with the most accurate representation? Explain why.


This exercise made me wonder why anyone would use float if they need precision from floating point numbers. Sure float is smaller than double so you would be saving bytes however you lose precision.

No comments:

Post a Comment