hasopolis.blogg.se

Planswift 10 round numbers
Planswift 10 round numbers




planswift 10 round numbers planswift 10 round numbers

And then we check if the last digit is less than or more than 5, in both cases the number is either degraded or incremented to the previous or next multiple of ten. So for this, we will use the “floor” function to separate the decimal numbers from its integer part. So we will have to have a different approach here such that it satisfies all the cases. And also floating-point numbers will not be solved using this technique.įor example, if we enter 73.5 in a float variable and then divide it by 10 we will get 7.35 and again multiplying by 10 will give us the original number back (73.5). But this poses a problem as even 28 or 29 which is closer to 30 will give us 20 in this case. If we take a whole number which is not a multiple of 10 and store it in an integer data type which is not capable of storing decimal values, we would then be able to divide that by 10 and then again multiply it by 10 and that would give us the required multiple of 10.įor example, 23 divided by 10 gives us 2.3 but the integer can only hold 2 and then we multiply it by 10 to give us 20. Now it should be noted that the program should be self-sufficient to run on any inserted number be it a whole number or a number having a decimal point. And if we give and input of 35.8 the program will give an output of 40. This means if we enter the number 21 the program will give an output 20.

Planswift 10 round numbers how to#

This tutorial will show you how to round off numbers to their nearest 10th multiple in C++.






Planswift 10 round numbers