Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to round to next biggest value example 1.1 to 2
Posted

You need to use Ceiling - Math.Ceiling[^].
E,g,
double value1 = 123.456;
double ceiling1 = Math.Ceiling(value1);

The output here will be 124.
 
Share this answer
 
Comments
[no name] 6-Oct-15 8:20am    
Exactly. My 5.
Abhinav S 6-Oct-15 8:26am    
Thanks.
SathishRam 6-Oct-15 8:46am    
Thanks lot it working !!!!!!!!!!!!!!!
If you want to round to the nearest int:

C#
int rounded = (int)Math.Round(precise, 0);

You can also use:

C#
int rounded = Convert.ToInt32(precise);


Which will use Math.Round(x, 0); to round and cast for you. It looks neater but is slightly less clear IMO.

If you want to round up:

C#
int roundedUp = (int)Math.Ceiling(precise);
 
Share this answer
 
Comments
SathishRam 6-Oct-15 8:44am    
1829.33 getting round to 1829, i need round next value 1830

My code:
1) Dim val As Integer = CInt(Math.Round(Price, 0))
2) Dim val1 as Integer=Convert.ToInt64(Price)

im getting 1829,but i need 1830

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900