I'm trying to figure out how to make a C++ function that always rounds up to the nearest tenth. For example:
A value of 20.5 would remain 20.5
A value of 20.51 would become 20.6
A value of 20.55 would become 20.6
And so on...
Unfortunately, the functions provided (ceil and floor) only work for whole number rounding, and almost everybody else uses normal rounding functions instead of always rounding up functions. Also, I would prefer a solution that does not hinder the accuracy of the floats in any way (I'm working with hardware and measuring to at least 3 decimal places).
@QuestionMaker2
Your name says it all. You are not here to learn, you are just here to make some random quizzes just for fun, and there is a risk that we spend our time answering your questions just for nothing.
Right? Is it your intention?
Edit: I didn't mean to sound negative (maybe it is funny) but I will be awaiting you with some clarifications.
in : 2921.863
out : 2921.9
in : 8902.22153883
out : 8902.3
in : 7527.587767
out : 7527.6
in : 3563.612789185
out : 3563.7
in : 3739.479
out : 3739.5
in : 5455.6
out : 5455.6
in : 6977.231697516
out : 6977.3
in : 4909.65
out : 4909.7
in : 6404.48
out : 6404.5
in : 5815.455781434
out : 5815.5
in : 14128.936
out : 14129.0
in : 7517.19
out : 7517.2
in : 3696.3
out : 3696.3
in : 3950.8
out : 3950.8
in : 10795.553
out : 10795.6
in : 5428.5
out : 5428.5
in : 13446.924974
out : 13447.0
in : 6915.758176514
out : 6915.8
in : 9716.9
out : 9716.9
in : 9619.82342813
out : 9619.9
in : 14781.371545129
out : 14781.4
in : 4073.793768
out : 4073.8
in : 10037.6587189
out : 10037.7
in : 7686.13436637
out : 7686.2
in : 12157.2
out : 12157.2
in : 1704.8
out : 1704.8
in : 6471.4
out : 6471.4
in : 10689.9286672
out : 10690.0
in : 2623.5337
out : 2623.6
in : 9230.14433
out : 9230.2
in : 1757.7543
out : 1757.8
in : 3655.47612
out : 3655.5
in : 636.3895554
out : 636.4
in : 270.4
out : 270.4
in : 3186.683823
out : 3186.7
in : 10081.577
out : 10081.6
in : 1195.85445
out : 1195.9
in : 10494.189725
out : 10494.2
in : 3329.177
out : 3329.2
in : 4597.38
out : 4597.4
in : 6096.565
out : 6096.6
in : 12594.4
out : 12594.4
in : 729.7
out : 729.8
in : 5794.867
out : 5794.9
in : 6533.8
out : 6533.9 // Wrong!!!
in : 9533.6793976
out : 9533.7
in : 3000.28
out : 3000.3
in : 9815.8241686
out : 9815.9
in : 7902.39
out : 7902.4
in : 3661.24
out : 3661.3