I need your help,
For example I have a decimal type variable and I want to round up this way.
Eg
3.0 = 3
3.1 = 4
3.2 = 4
3.3 = 4
3.4 = 4
3.5 = 4
3.6 = 4
3.7 = 4
3.8 = 4
3.9 = 4
4.0 = 4
4.1 = 5
4.2 = 5
etc....
How can I do that?
Very Simple, the trick is the Ceiling function provided by most of the programming. For instance in C#, it is a staic method inside the Math namespace;
namespace ConsoleDebugger { class Program { static void Main(string[] args) { int lowerLimit = 3; int upperLimit = 10;
int index = 0;
for (int i = lowerLimit; i < upperLimit; i++)
{
for (int j = 0; j < 10; j++)
{
string value = i + "." + j;
Console.WriteLine( value + " " + Round(double.Parse(value)));
}
if (index == 10)
index = 0;
}
Console.ReadLine();
}
private static double Round(double number)
{
return Math.Ceiling(number);
}
}
}