ASP.NET VB - some mathematics with .NET
I need your help,
For example, I have a variable of decimal type and I want to round this path.
For example,
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 this?
Math.Ceiling
dim rounded as int = Math.Ceiling(4.1)
(a bit rusty on VB syntax, so it can't be in perfect, compiled syntax)
maybe you should parse the char and the desimal value should be checked ... a = 3,4 = str CSTR (a) b = substring (str, 0,1) c = substring (stra, 2,1)
d = CInt (c) f = CInt (b)
if d> 0, then e + 1 = end, if
Very simple, the trick is the ceiling feature provided by most programs. For example, in C # it is a static method inside the Math namespace;
namespace ConsoleDebugger {cool 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);
}
}
}