Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do round int with Ceiling

Tags:

c#

rounding

how do i convert value and round off int values?

Example:

int x = 121;
int y = Math.Ceiling(x/8);

Get Error:

Cannot implicitly convert type double to int. An explicit conversion exists (are you missing a cast?)

like image 287
shahin ko Avatar asked Sep 01 '13 17:09

shahin ko


People also ask

Does CEILING function round up?

CEILING works like the MROUND function, but CEILING always rounds up. The Excel EVEN function rounds numbers up to the next even integer. The EVEN function always rounds numbers away from zero, so positive numbers become larger and negative numbers become smaller (i.e. more negative).

How do you use CEILING formula?

Description. Returns number rounded up, away from zero, to the nearest multiple of significance. For example, if you want to avoid using pennies in your prices and your product is priced at $4.42, use the formula =CEILING(4.42,0.05) to round prices up to the nearest nickel.

Does Math Ceil return an INT?

Math. ceil(<some value>) returns a double, not an integer.

What does CEILING () mean in Excel?

Returns a number rounded up to a supplied number that is away from zero to the nearest multiple of a given number.


1 Answers

You can try using this:-

 int x = 121;
 int y = (int)Math.Ceiling((double)x/8);     
like image 193
Rahul Tripathi Avatar answered Sep 23 '22 10:09

Rahul Tripathi