Answer the question
In order to leave comments, you need to log in
How to write only two decimal places?
I have three numbers that look like this:
x = 0.154848784
y = 0.88787754
z = 0.4848484455
At the same time, during the execution of the program, these numbers change and the number of decimal places too, I need the program to write to me only 2 decimal places of these values.
For example: x = 0.154848784 and in the console it should write x = 0.15
Answer the question
In order to leave comments, you need to log in
How to print has already been explained to you. And here is the answer to the "why" question: Float in C, 0.41 is actually 0.40999
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question