Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb.net: rounding to next whole number

Tags:

.net

vb.net

if i have an integer a_variable = 1.1

how do i round it up to 2?

like image 569
Alex Gordon Avatar asked Dec 15 '09 20:12

Alex Gordon


People also ask

How do I round a number in VB net?

The basic function for rounding up is Math. Ceiling(d), but the asker specifically wanted to round up after the second decimal place. This would be Math. Ceiling(d * 100) / 100.

What is round () in VB net?

The Round method supports two rounding conventions for handling midpoint values: Rounding away from zero. Midpoint values are rounded to the next number away from zero. For example, 3.75 rounds to 3.8, 3.85 rounds to 3.9, -3.75 rounds to -3.8, and -3.85 rounds to -3.9.

How do you round off to next number in C#?

In C#, Math. Round() is a Math class method which is used to round a value to the nearest integer or to the particular number of fractional digits. This method has another overload with which, you can specify the number of digits beyond the decimal point in the returned value.

Does C# round up or down?

50000001" will always round up and ". 4999999" will always round down the the nearest integer. So a 15.5 can never become a 14. Any value that is larger than 14.5 and smaller than 15.5 will round to 15 any value larger than 15.5 and smaller than 16.5 will round to 16.


1 Answers

Math.Ceiling(a_variable)

like image 183
xster Avatar answered Sep 26 '22 15:09

xster