Hi, this is the post about the WSQ05.

The huge problem in this one was about controlling the output to not write all the numbers that the “float” storage have.

Here we go:

WSQ05

I think everything in the program is easy, except by the “setprecision” stuff. Let’s talk about it:
“setprecision” is a function, included in “iomanip” (this means that if you want to use setprecision you will have to include the <iomanip> library). “iomanip” Refers to input/output manipulation, and “setprecision” allows you to control how many numbers do you want to return. I guess this is often used when working with float and double, because we do not want to print a number like 132.2356492, because it is just not good, so we use setprecision and turn it into a pretty 132.24 or 132.236,  it looks great and also is a better way to work with numeric values.

The way to use setprecision is quite simple, when your call cin or cout, you just put:

>>/<< setprecision (x) >>/<< (ignore parenthesis and here the variable that you want to control);

The x value is how many numbers do you want to appear when printing or to take when entering.

Any questions, I am gladly answering. Have a nice day.

Here is the code: https://github.com/hrglez/TC1017/blob/master/WSQ05%20-%20%C2%B0F%20to%20%C2%B0C

CC BY 4.0 WSQ05, Degrees by hrglez is licensed under a Creative Commons Attribution 4.0 International License.