P
P
Pavel K2015-08-23 03:36:11
Mathematics
Pavel K, 2015-08-23 03:36:11

C++ Flour rounding. How to "beautifully" make the following functions?

Greetings!
There is, for example, a number of type double
43.210002 ; leave the number up to hundredths, fill in the rest with zeros (for example, up to 4 after hundredths). it is also required then just to remove the point i.e. make the number "integer" without rounding. I did it through the line, but it looks like an infernal crutch. Tell me, please, what is the right way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ColdSpirit, 2015-08-23
@PavelK

stackoverflow.com/questions/14369673/c-round-double...
Sorry, I misunderstood the question.
I would create a class or struct with a double containing the number 43.21 and an int containing the number of zeros after the decimal point. Well, and other functions for converting standard types into yours and vice versa.
Well, or just write a set of conversion functions from one type to another, if you do not need to perform operations with this type of numbers, but simply output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question